I'm in the process of building an IoT device using ESP8266. The device will eventually contain a couple of motors, and I would like to control these motors using MQTT. I would like to make the device as cheap as possible, so I would like to avoid things like displays and keyboards.
So, when the device is turned it is supposed to connect to the local WiFi, and then to an MQTT broker. But how does it know about the local SSID to connect to, and what about username and password? Since the device has no display or keyboard, there is no way to input these things. And how does the user know if the device was able to connect or not? For troubleshooting, it would be nice if the device at least had some way to indicate what the problem might be.
The solution I have thought of is to have one button and one LED on the device. The button would be marked "config" or similar. When the button is pressed, the device will start operating as a WiFi access point with a predefined SSID. It will have a webserver, so the user can connect with a laptop or phone to this predefined access point and enter the local network settings (SSID, username and password) as well as the address for the MQTT broker. The LED will be used to indicate the mode of operation, and also as error indication. For example, when the LED is glowing steady everything is connected, long flashes means it is in config mode, short flashes means there is an error, or something similar.
My question is, is the solution I have proposed a standard way of doing things when it comes to this problem? I.e. will it feel like a familiar flow to the user, or would some other way be better? After doing a little bit of searching I have found e.g. this, which seems to be a similar user flow. Would still be interested in hearing what experience you have of this, and hear how you would solve it?
If it turns out that this is a good and useful way to solve this problem, and since it is a kind of generic solution, it would be nice to not reinvent the wheel too much. I'm thinking that there could be a library that could do all of this. The library would be configured with the input pin for the button and output pin for the LED, and then take care of the rest. It could be built upon the PubSubClient library and based on the tutorial ESP8266: Connecting to MQTT broker. So is there a library that does this or something similar? If not I'll take a stab and create my own, but would like to hear about what's out there first.
Thanks!