Originally shared by Phil H
I’ve been playing with the @Adafruit_Industries Feather Huzzah with ESP8266 WiFi for the last few weeks. This board has a nice small physical form factor, is 99% compatible with Arduino code that’s been written for other boards, and is ideal for building relatively low complexity Internet of Things devices. It can be powered from a USB input or Lithium Polymer battery (which can also be charged via the USB port).
What bugged me though was the need to hardwire my wifi network SSID and password into every program I wrote, so I decided to develop what I’m calling an IoT application foundation.
The application foundation would have two boot modes - configuration mode and client mode.
In configuration mode the ESP8266 starts up as a WiFi hotspot. Connecting to the hotspot allows you to access a web page through which you can configure the WiFi network SSID and password that the device should use when running in client mode. Once set you can reboot the device into client mode, also through the web page.
In client mode the ESP8266 starts up as a WiFi client and joins a WiFi network using the previously configured SSID and password, after which it can then interact on the network using HTTP and, if necessary, the built-in web server.
Of course there needs to be a way to get the device back into configuration mode when it is running in client mode. One way of doing this is by hitting a particular URL on the device’s web server - /rebootInConfigurationMode - which causes the ESP8266 to reboot in configuration mode.
But what if your client network details are incorrect, or the network is no longer available? Well this is also catered for. When starting up in client mode, if it takes longer than 30 seconds to connect to the network the device configuration is updated so that on the next power cycle (or press of the reset button) it will start up in configuration mode. If the device does eventually connect, the instruction to start up in configuration mode is revoked.
So far I’ve used the IoT application foundation to build a NeoPixel notification panel - a project I’ll document separately (currently it simply notifies me if my home broadband connection is down). I’ve other projects planned, and alongside those I’ll be adding features to, and improving the underlying code of, the IoT application framework - as well as improving the visual presentation of the configuration web pages.
I plan to open source the framework once the codebase is stable and I’ve put together enough documentation to support third party use.
#IoT esp8266 #Adafruit #OpenSource