Note: For a great codeless method for flashing your ESP devices try the fantastic ESPHome project->
https://esphome.io/
ESP32/ESP8266 library that extends the WiFiManager and PubSub Client Libraries and adds the ability to save SSID, WiFi password, and MQTT connection settings so that they don't have to be hard-coded in your sketches. Also allows for user friendly naming of your IoT devices and publishes device registration data back to a Node Red Dashboard where you can initiate service actions on your devices (e.g. restart, or bring up it's access point to reconfigure/rename device, etc)
It's assumed that you already know how to setup an Arduino development environment, including how to install libraries, and that you already have MQTT and Node Red/Dashboard installed.
First cut at a library. Contributions are welcome.
- WiFiManager Library (must use development branch)
- Arduino Json Library
- PubSub Client Library
- NOTE: Change MQTT_MAX_PACKET_SIZE in PubSubClient.h to 512
- Install the required libraries (see above)
- Download WiFiMQTTManager and unzip it in your Arduino libraries folder. Make sure the folder name is "WiFiMQTTManager".
- Edit the PubSubClient.h header file and change MQTT_MAX_PACKET_SIZE to 512
- Import (then Deploy) into Node Red the Dashboard json found in /nodered/services-export.json file (make sure you enter your MQTT server address in the two MQTT nodes in the flow)
- Open Arduino IDE and attach your ESP32 or ESP8266 controller board to your computer (select the correct board and port)
- In Arduino IDE open File->Examples->WiFiMQTTManager->Basic sketch
- Change the AP_PASSWORD in secrets.h file to a suitable password for your device Access Points
- Upload the sketch to your device (you may need to uncomment the wm.formatFS = true; line in the basic sketch but if you do make sure you comment it back out and re-load your sketch after the device file system is formatted) (the serial monitor window will show helpful information)
- After a few seconds you should see a new SSID in your available WiFi Access Points in the formap of ESP_xxxxxxxx. Select this SSID and a new configuration popup window will appear.
- Enter your SSID and password, your MQTT server address and port and give your device a user friendly name
- A few seconds after your device is configured you should see the new device show up in the Service Dashboard dropdown widgets.
For issues, feature requests, comments or questions, use the Github issues tracker.
- Fork the project.
- Create your feature branch: git checkout -b my-new-feature
- Commit your changes: git commit -am 'Add some feature'
- Push to the branch: git push origin my-new-feature
- Submit a pull request.
Dec 10, 2018 - Version 1.0.0-beta released
- AlexT - author of WiFiManager
- Nick O'Leary - author of PubSub Client
GNU GPL, see License.txt