ESP8266-MyWidget
This demo includes:
- ESP8266 Development
- mDNS - multicast DNS (mywidget.local)
- Asynchronous Web Server (ESPAsyncWebServer)
- Asynchronous Web Services (ESPAsyncWebServer)
- Asynchronous MQTT (PangolinMQTT)
- LittleFS File System
- Embedded Bootstrap (3.4.1)
- Embedded jquery (3.5.1)
- Save/Load Config File (text)
- OTA (Over the Air) Updates
- HTTP API Supports HTTP GET/POST
- Auto Updating Web Site (Web Services using JS)
- Multiple Interrupt Timers (ESP8266TimerInterrupt)
- Flash Onboard LED Using Interrupt Timer
- Plus much more...
History
ESP8266-MyWidget can be used as a learning tool or as a template for starting a new ESP8266 project. I tried to incorporate many APIs that may be useful for a ESP8266 project with a web interface.
Requirements
- Adruino for ESP8266 - Arduino core for ESP8266
- Arduino ESP8266 LittleFS Filesystem Uploader - Arduino plugin for uploading files to LittleFS
Extract the folder in each of these zip files and place it in the "library" folder under your arduino environment
- ESPAsyncTCP - Asynchronous TCP Library
- ESPAsyncWebServer - Asynchronous HTTP and WebSocket Server for ESP8266 Arduino
- PangolinMQTT - Asynchronous MQTT client library
- ESP8266TimerInterrupt - Supports 16 ISR-based timers
Features
mDNS - multicast DNS
- Mulicast DNS allows you to use a local DNS name (mywidget.local) to access the web interface.
- There is no need to know the local IP address obtained from the WIFI connection.
- mDNS will resolve the IP address for you.
- Enter the following into browser: http://mywidget.local
Web Services
- Asynchronous
- Supports GET and SET ACTIONS
- Formats:
- cmd:get:action
- cmd:set:action
- All requests and responses are in TEXT format.
- GET ACTIONS
- Uptime - Returns device uptime in milliseconds.
- Request: ''cmd:get:uptime''
- Response: ''cmd:get:uptime:NNNNNNNN''
- where NNNNNNNN is the device uptime in milliseconds
- Status - Returns status of light (0/1)
- Request: ''cmd:get:status''
- Response: ''cmd:get:status:N''
- where N is "0" or "1" representing "OFF" or "ON" of light
- Speed - Returns flash speed of onboard LED
- Request: ''cmd:get:speed''
- Response: ''cmd:get:speed:N''
- where N is "1" to "4" representing representing flash speed of onboard LED
- Config - Returns current configuration parameters. Read from /cfg.txt file.
- Request: ''cmd:get:config''
- Response: ''cmd:get:config:channels:ports:user1:user2''
- where channels is NNN, ports is NN, user1 is XXXXX, user2 is XXXXXX
- SET ACTIONS
- Toggle - Toggles the current light from 0 to 1 or 1 to 0
- Request: ''cmd:set:toggle''...