Last month I have been working on a ESP-IDF component that allows configuring multiple settings on ESP32 from a smartphone. Working on some IoT device firmware, I saw myself repeating the same code over and over. For example, to setup WiFi I have a variable called ssid and I have to write its code for:
- Show its content on a configuration webpage
- Save the new value submitted via the webpage
- Write its content on flash
- Read its startup value from flash on every boot
It might not look like a lot, but now I have to write almost the same code for the password. Later, I needed to include some other settings containing user preferences, and maintining that code was becoming a nightmare. To accomplish this with the «color» setting (just an example), I keep the code that reads and writes on flash in the module where all the flash magic happens, the code to show its value and the ability to updated via web with the web stuff, and last but not least, the code where the setting is actually used. Any change of this parameter means editing code in 3 different places, duh!
For every setting the code is extremely similar though, the major differences are the name of the setting, the data type and how it is shown on the webpage… There must be a way to make this simple!
That is why I created esp32-manager
esp32-manager helps with the configuration and management of settings on ESP32.
- Simplifies reading from and writing to flash using NVS for any variable in your application. Just register any variable with esp32_manager and you will get simple read and write functions for NVS.
- Easy WiFi connection to networks or creation of APs. Automatic AP creation for WiFi configuration.
- Creates a web interface to configure any setting in your application registered with esp32_manager.
- Easily publish values to MQTT in a structured and consistent way.
Find the project on GitHub, where I will also keep it updated with new additions and features: https://github.com/pablobacho/esp32-manager