├── data ├── cfg.txt ├── cplusplus.png ├── index.html ├── config.html └── js │ ├── bootstrap.min.js │ └── jquery.min.js ├── images ├── home-page.png └── config-page.png ├── LICENSE ├── README.md ├── README.html └── ESP8266-MyWidget-Demo.ino /data/cfg.txt: -------------------------------------------------------------------------------- 1 | 512:8:default1:default2 -------------------------------------------------------------------------------- /data/cplusplus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onewithhammer/ESP8266-MyWidget-Demo/HEAD/data/cplusplus.png -------------------------------------------------------------------------------- /images/home-page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onewithhammer/ESP8266-MyWidget-Demo/HEAD/images/home-page.png -------------------------------------------------------------------------------- /images/config-page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onewithhammer/ESP8266-MyWidget-Demo/HEAD/images/config-page.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Tony Keith 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /data/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ESP8266 MyWidget - Home Page 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 41 |
42 |
43 |
44 |
This Demo Features
45 |
46 |
    47 | 48 |
  • 49 | ESP8266 Development 50 |
  • 51 |
  • 52 | mDNS - multicast DNS Support (mywidget.local) 53 |
  • 54 |
  • 55 | Async Web Server (ESPAsyncWebServer) 56 |
  • 57 |
  • 58 | Async Web Services (ESPAsyncWebServer) 59 |
  • 60 |
  • 61 | Async MQTT (PangolinMQTT) 62 |
  • 63 |
  • 64 | LittleFS File System 65 |
  • 66 |
  • 67 | Embedded Bootstrap (3.4.1) 68 |
  • 69 |
  • 70 | Embedded html, css, JS and Images 71 |
  • 72 |
  • 73 | Save/Load Config File (text) 74 |
  • 75 |
  • 76 | OTA (Over the Air) Updates 77 |
  • 78 |
  • 79 | HTTP GET/POST Method w TEXT/JSON response 80 |
  • 81 |
  • 82 | API Web Services 83 |
  • 84 |
  • 85 | Dynamically Updating Web Site (Web Services using JS) 86 |
  • 87 |
  • 88 | Multiple Interrupt Timers (ESP8266TimerInterrupt) 89 |
  • 90 |
  • 91 | Flash Onboard LED Using Interrupt Timer 92 |
  • 93 |
    94 |
95 |
96 |
97 |
98 |
99 |
100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ESP8266-MyWidget 2 | 3 | [![GitHub release](https://img.shields.io/github/release/onewithhammer/ESP8266-MyWidget-Demo.svg)](https://github.com/onewithhammer/ESP8266-MyWidget-Demo/releases) 4 | [![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/onewithhammer/ESP8266-MyWidget-Demo/blob/master/LICENSE) 5 | [![GitHub issues](https://img.shields.io/github/issues/onewithhammer/ESP8266-MyWidget-Demo.svg)](http://github.com/onewithhammer/ESP8266-MyWidget-Demo/issues) 6 | 7 | ![Config Page](images/config-page.png) 8 | 9 | This project can be used as a framework, learning tool or as a template for starting a new ESP8266 project. 10 | It contains many of the components to build a ESP8266 project with dynamic web interface. 11 | 12 | This project includes: 13 | 14 | - ESP8266 Development 15 | - mDNS - multicast DNS (mywidget.local) 16 | - Asynchronous Web Server (ESPAsyncWebServer) 17 | - Asynchronous Web Services (ESPAsyncWebServer) 18 | - Asynchronous MQTT (PangolinMQTT) 19 | - LittleFS File System 20 | - Embedded Bootstrap (3.4.1) 21 | - Embedded jQuery (3.5.1) 22 | - Embedded html, css, JS and Images 23 | - Save/Load Config File (text) 24 | - OTA (Over the Air) Updates 25 | - HTTP API Supports HTTP GET/POST 26 | - Dynamically Updating Web Site (Web Services using JS) 27 | - Multiple Interrupt Timers (ESP8266TimerInterrupt) 28 | - Flash Onboard LED Using Interrupt Timer 29 | - Plus much more... 30 | 31 | ## History 32 | 33 | I purchased several [ESPixelSticks](https://www.amazon.com/dp/B072XT1V77/ref=cm_sw_em_r_mt_dp_-RscGb7XH5PQ3) from Amazon for my synchronized LED Christmas light display. After using the ESPixelSticks, I became interested in how the ESP8266 worked and how to program it. So I began to review the [ESPixelStick](https://github.com/forkineye/ESPixelStick) source code and the specifications of the ESP8266. It didn't take long to find out there is an add-on for the Arduino IDE that allows you to program the ESP8266 using the Arduino IDE and its programming language. A few years back, I had created some simple projects using Arduino UNO R3 and programmed using the Arduino IDE. Since I was already familiar with the Arduino IDE, I started by modifying some of the simple examples and playing with different libraries. I wasn't very interested in the low level hardware or interfacing to a sensor/module but I was more interested in an interactive UI and different ways to communicate with this device. I didn't have a particular project in mind so I created ESP8266-MyWidget; A project template for ESP8266. 34 | 35 | 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. 36 | 37 | ## Requirements 38 | 39 | ESP8266-based development board - I used the Wemos D1 Mini 40 | 41 | Along with the Arduino IDE, you'll need the following software to build this project: 42 | 43 | - [Adruino for ESP8266](https://github.com/esp8266/Arduino) - Arduino core for ESP8266 44 | - [Arduino ESP8266 LittleFS Filesystem Uploader](https://github.com/esp8266/arduino-esp8266fs-plugin) - Arduino plugin for uploading files to LittleFS 45 | 46 | The following libraries are required: 47 | 48 | Extract the folder in each of these zip files and place it in the "library" folder under your arduino environment 49 | 50 | - [ESPAsyncTCP](https://github.com/me-no-dev/ESPAsyncTCP) - Asynchronous TCP Library 51 | - [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) - Asynchronous HTTP and WebSocket Server for ESP8266 Arduino 52 | - [PangolinMQTT](https://github.com/philbowles/PangolinMQTT) - Asynchronous MQTT client library 53 | - [ESP8266TimerInterrupt](https://github.com/khoih-prog/ESP8266TimerInterrupt) - Supports 16 ISR-based timers 54 | 55 | ## Features 56 | 57 | --- 58 | 59 | ## mDNS - multicast DNS 60 | 61 | - Mulicast DNS allows you to use a local DNS name (mywidget.local) to access the web interface. 62 | - There is no need to know the local IP address obtained from the WIFI connection. 63 | - mDNS will resolve the IP address for you. 64 | 65 | - Enter the following into browser ``http://mywidget.local`` 66 | 67 | ## Web Services 68 | 69 | - Asynchronous 70 | - Supports GET and SET ACTIONS 71 | - Formats: 72 | - cmd:get:action 73 | - cmd:set:action 74 | - All requests and responses are in TEXT format. 75 | 76 | - GET ACTIONS 77 | 78 | - Uptime - Returns device uptime in milliseconds. 79 | - Request: ''cmd:get:uptime'' 80 | - Response: ''cmd:get:uptime:NNNNNNNN'' 81 | - where NNNNNNNN is the device uptime in milliseconds 82 | 83 | - Status - Returns status of light (0/1) 84 | - Request: ''cmd:get:status'' 85 | - Response: ''cmd:get:status:N'' 86 | - where N is "0" or "1" representing "OFF" or "ON" of light 87 | 88 | - Speed - Returns timer speed of interrupt handler 89 | - Request: ''cmd:get:speed:X'' 90 | - Response: ''cmd:get:speed:X:N'' 91 | - where X is the "1" to "3" representing the number of the interrupt handler 92 | - where N is "1" to "4" representing speed of the interrupt timer 93 | 94 | - Config - Returns current configuration parameters. Read from /cfg.txt file. 95 | - Request: ''cmd:get:config'' 96 | - Response: ''cmd:get:config:channels:ports:user1:user2'' 97 | - where channels is NNN, ports is NN, user1 is XXXXX, user2 is XXXXXX 98 | 99 | - SET ACTIONS 100 | 101 | - Toggle - Toggles the current light from 0 to 1 or 1 to 0 102 | - Request: ''cmd:set:toggle'' 103 | - Response: ''cmd:set:toggle:N'' 104 | - where N is "0" or "1" representing "OFF" or "ON" of light 105 | 106 | - Speed - Sets the timer speed of interrupt handler 107 | - Request: ''cmd:set:speed:X:N'' 108 | - Response: ''cmd:set:speed:X:N'' 109 | - where X is the "1" to "3" representing the number of the interrupt handler 110 | - where N is "1" to "4" representing speed of the interrupt timer 111 | 112 | - Config - Sets current configuration parameters. Saved to /cfg.txt file. 113 | - Request: ''cmd:set:config:config:channels:ports:user1:user2'' 114 | - Response: ''cmd:set:config:channels:ports:user1:user2'' 115 | - where channels is NNN, ports is NN, user1 is XXXXX, user2 is XXXXXX 116 | 117 | ## Web Server 118 | 119 | - Asynchronous 120 | - Supports serving embedded html, css, js files 121 | - Supports serving embedded images 122 | - Sets default to index.html 123 | - Serves two embedded web pages (index.html & config.html) 124 | - Supports file not found message 125 | 126 | ## User Interface 127 | 128 | - Nav Bar Menu 129 | - Home and Config pages implemented 130 | - Displays Current Light Output 131 | - State1 field updates on page load and when the "Toggle" button is pressed 132 | - Displays Current Device Configuration 133 | - Channels, ports, user1 and user2 fields update on page load 134 | - Channels, ports, user1 and user2 are input fields 135 | - Channels, ports, user1 and user2 can be modified and are saved when "Save Changes" button is pressed 136 | - Displays Current Device Uptime 137 | - Uptime is updated on a 1 second basis 138 | - Uptime format is: "N days, HH:MM:SS" 139 | - Displays Current LED Flash Speed 140 | - Select input allows onboard LED speed to be changed 141 | - LED speed is updated on select input change 142 | - All messages to/from config page use Web Services 143 | - Web Services has queue implemented if server is busy 144 | - Implemented using embedded Bootstrap (3.4.1) 145 | - Implemented using embedded JQuery (3.5.1) 146 | 147 | ## HTTP API - GET and POST 148 | 149 | - Asynchronous 150 | - HTTP GET FREE HEAP (TEXT) 151 | - URL: `http://mywidget.local/heap` 152 | - Returns free heap space 153 | - Request: 154 | - Name/Value Pair: N/A 155 | - Response: 156 | - freeHeap=[Free Heap] 157 | - Example Request: 158 | - `http://mywidget.local/heap` 159 | - Example Response: 160 | - `freeHeap=38616` 161 | 162 | - HTTP GET INTERRUPT COUNT (TEXT) 163 | - URL: `http://mywidget.local/intcount + optional query string parameters` 164 | - Returns interrupt counter(s) based on query string parameters, if no query string parameters, then intcount1 165 | - Request: 166 | - Query String Parameters: N/A 167 | - Response: 168 | - `:intcount1=[Interrupt Counter]` 169 | - Example Request: 170 | - `http://mywidget.local/intcount` 171 | - Example Response: 172 | - `:intcount1=4533456` 173 | 174 | - Query string parameters (optional): 175 | - Request: 176 | - 1=true, 2=true, 3=true 177 | - Response: 178 | - Interrupt Counter(s) based on query string 179 | - Name value pairs are delimited using colon ":". 180 | - Name and value fields are delimited using a equal "=" sign. 181 | - Example Request: 182 | - `http://mywidget.local/intcount?1=true&2=true&3=true` 183 | - Example Response: 184 | - `:intcount1=4533456:intcount2=23236:intcount3=98434445` 185 | - Example Request: 186 | - `http://mywidget.local/intcount?3=true` 187 | - Example Response: 188 | - `:intcount3=98434445` 189 | 190 | - HTTP GET INTERRUPT COUNT2 (TEXT) 191 | - URL: `http://mywidget.local/intcount2` 192 | - Returns interrupt counter 2 - interruptCounter2 variable 193 | - Request: 194 | - Query String Parameters: N/A 195 | - Response: 196 | - `:intcount2=[Interrupt Counter 2]` 197 | - Example Request: 198 | - `http://mywidget.local/intcount2` 199 | - Example Response: 200 | - `:intcount2=23236` 201 | 202 | - HTTP GET INTERRUPT COUNT3 (TEXT) 203 | - URL: `http://mywidget.local/intcount3` 204 | - Returns interrupt counter 3 - interruptCounter3 variable 205 | - Request: 206 | - Query String Parameters: N/A 207 | - Response: 208 | - `:intcount3=[Interrupt Counter 3]` 209 | - Example Request: 210 | - `http://mywidget.local/intcount3` 211 | - Example Response: 212 | - `:intcount3=98434445` 213 | 214 | - HTTP GET STATUS (TEXT) 215 | - URL: `http://mywidget.local/status + query string (name/value pairs)` 216 | - Returns status about network, filesystem, signal, heap and chip info in text format. 217 | - Name value pairs are delimited using colon ":". 218 | - Name and value fields are delimited using a equal "=" sign. 219 | 220 | - HTTP GET SYSTEM STATUS (JSON) 221 | - URL: `http://mywidget.local/status-json + query string (name/value pairs)` 222 | - Returns status about network, filesystem, signal, heap and chip info. 223 | 224 | - Query string (name/value pairs) parameters: 225 | 226 | - Network 227 | - Request: 228 | - Name/Value Pair: network=true 229 | - Response:: 230 | - ssid=[SSID] 231 | - hostname=[Hostname] 232 | - ip=[IP Address] 233 | - gateway=[Gateway] 234 | - netmask=[Netmask] 235 | 236 | - Filesystem 237 | - Request: 238 | - Name/Value Pair: fs=true 239 | - Response:: 240 | - totalBytes=[Total Bytes] 241 | - usedBytes=[Used Bytes] 242 | 243 | - Signal 244 | - Request: 245 | - Name/Value Pair: signal=true 246 | - Response:: 247 | - strength=[Signal Strength] 248 | 249 | - Heap 250 | - Request: 251 | - Name/Value Pair: heap=true 252 | - Response:: 253 | - freeHeap=[Free Heap] 254 | 255 | - Chip Info 256 | - Request: 257 | - Name/Value Pair: chipInfo=true 258 | - Response:: 259 | - chipId=[Chip ID] 260 | - flashChipId=[Flash Chip ID] 261 | - flashChipSize=[Flash Chip Size] 262 | - flashChipRealSize=[Flash Chip Real Size] 263 | 264 | - Example Request: 265 | - `http://mywidget.local/status?network=true&fs=true&signal=true&heap=true&chipInfo=true` 266 | - Example Response (TEXT): 267 | - `:network=true:ssid=MyWifi:hostname=mywidget:ip=192.168.0.20:gateway=192.168.0.1:netmask=255.255.255.0:signal=true:strength=-68:chipInfo=true:chipId=3016621:flashChipId=1458392:flashChipSize=4194304:flashChipRealSize=4194304:heap=true:freeHeap=38216:fs=true:totalBytes=1024000:usedBytes=327680` 268 | 269 | - Example Request: 270 | - `http://mywidget.local/status-json?network=true&fs=true&signal=true&heap=true&chipInfo=true` 271 | - Example Response (JSON): 272 | 273 | `{"network": { 274 | "ssid": "MyWifi", 275 | "hostname": "mywidget", 276 | "ip": "192.168.0.20", 277 | "gateway": "192.168.0.1", 278 | "netmask": "255.255.255.0" 279 | }, 280 | "signal": { 281 | "strength": "-78" 282 | }, 283 | "chipInfo": { 284 | "chipId": "3016621", 285 | "flashChipId": "1458392", 286 | "flashChipSize": "4194304", 287 | "flashChipRealSize": "4194304" 288 | }, 289 | "heap": { 290 | "freeHeap": "38024" 291 | }, 292 | "fs": { 293 | "totalBytes": "1024000", 294 | "usedBytes": "327680" 295 | }}` 296 | 297 | - HTTP POST COUNTER 298 | - `http://mywidget.local/counter + query string (name/value pairs) in Request Body` 299 | - Sets the internal counter to Request counter value. Range 1 to 9999 300 | - Request: 301 | - Name/Value Pair: counter=XXXX 302 | - Response: 303 | - "POST: Counter set to: XXXX" 304 | 305 | - Example Request: 306 | - `POST ' 307 | - `form data in Request Body - counter=109` 308 | 309 | - Example Response (TEXT): 310 | - `POST: Counter set to: 109` 311 | 312 | ## File System 313 | 314 | This project is implmented using the LittleFS file system. All data is placed in a 'data' directory. 315 | 316 | Here is the directory and files associated with this project. 317 | 318 | data (Directory)` 319 | css (Style Sheet Directory) 320 | bootstrap.min.css (bootstrap CSS file) 321 | js (Java Script directory) 322 | bootstrap.min.js (bootstrap JS file) 323 | jquery.min.js (jquery JS file) 324 | cfg.txt (config file - text format) 325 | index.html (index file - HTML page) 326 | config.html (config file - HTML page) 327 | cplusplus.png (image file) 328 | 329 | If you modify a file locally, you must upload to device using [Arduino ESP8266 LittleFS Filesystem Uploader](https://github.com/esp8266/arduino-esp8266fs-plugin) 330 | 331 | The LittleFS implementation for the ESP8266 supports filenames of up to 31 characters + terminating zero (i.e. char filename[32]), and as many subdirectories as space permits. Keep your filenames + directories names short! 332 | 333 | ## MQTT (Message Queuing Telemetry Transport) - IoT messaging 334 | 335 | MQTT is implemented when a subscribe message is received, a corresponding publish message is sent. 336 | 337 | - Subscribe 338 | - esp32/get/uptime - Request uptime 339 | - Response: Publish: esp32/uptime (payload:text:"NNNNNNNN") 340 | - where NNNNNNNN is the device uptime in milliseconds 341 | 342 | - esp32/get/heap - Request current heap size 343 | - Response: Publish: esp32/heap (payload:text:"NNNNNN") 344 | - where NNNNNN is the current heap size 345 | 346 | - esp32/get/counter - Request current counter value and increment 347 | - Response: Publish: esp32/counter (payload:text:"NNNNNN") 348 | - where NNNNNN is the current counter value. 349 | - Counter is incremented after every esp32/get/counter received. Range 1 to 9999 350 | 351 | - esp32/set/counter (payload:"NNNNNN") - Set counter value to payload value (text) 352 | - Response: Publish: esp32/counter (payload:text:"NNNNNN") 353 | - where NNNNNN is the current counter value (text). Range 1 to 9999 354 | 355 | ## OTA (Over The Air) Updates 356 | 357 | OTA (Over The Air) Updates allows you to update the firmware on the device without being connected via a USB cable. The updates can occur after the device is connected to WIFI. The initial firmware installation requires using a USB cable but all subsequent updates can be perform remotely over WIFI. 358 | 359 | ## Interrupt Handler 360 | 361 | This project has a interrupt timer used to flash the onboard LED. 362 | 363 | - ESP8266 has only 2 hardware timers, named Timer0 and Timer1 364 | - Timer0 has been used for WiFi and it's not advisable to use while using WiFi 365 | - This means there is only 1 usable timer 366 | 367 | The original implementation used timer1 368 | 369 | Then I discovered [ESP8266TimerInterrupt](https://github.com/khoih-prog/ESP8266TimerInterrupt) which supports 16 ISR-based timers. 370 | 371 | - The main interrupt timer is setup for 10 millisecond interval 372 | 373 | - One ISR-based timer is used to flash the onboard timer and increment counter 374 | - interruptCounter1 (changeable speed / freq) 375 | - Second ISR-based timer is used to increment counter 376 | - interruptCounter2 (fixed speed / freq) 377 | - Third ISR-based timer is used to increment counter 378 | - interruptCounter3 (fixed speed / freq) 379 | 380 | ## Test & Debug 381 | 382 | I used a few different tools to test and debug. The source code was mainly debugged using Serial.print() messages and the Serial Monitor (Tools->Serial Monitor) in the Arduino IDE. 383 | 384 | I also used the Firefox web developer tools (console & network) debug the JavaScript and web services requests / responses. 385 | 386 | To test and debug the HTTP GET and POST requests/response messages, I used [POSTMAN](https://www.postman.com/) 387 | 388 | To test and debug MQTT, I used Mosquitto and Node-Red. 389 | 390 | ## Notes 391 | 392 | I orginally tried to send / receive JSON messages using the popular Arduino JSON Library [ArduinoJson](https://github.com/bblanchon/ArduinoJson) but I couldn't make it stable. I kept getting exceptions happening in various places, while stress testing (calling GET heap repeatively), so I eventually removed the ArduinoJson library and references. I converted all Web Services messages to send/receive text messages. I also converted files to save as text files (cfg.txt) instead of JSON. 393 | 394 | Later I went back and added an HTTP GET with JSON response example without any JSON libraries. 395 | 396 | - The Web Services messages text using fields delimited with colons ":". 397 | - The config files are also text using fields delimited with colons ":". 398 | 399 | ## Future Enhancements 400 | 401 | - [X] Support multiple interrupt timers (ESP8266TimerInterrupt) 402 | - [X] Support dynamic interval timers on config page 403 | - [X] Support HTTP GET INTERRUPT COUNT with optional parameters 404 | - [X] Embedded image support 405 | - [ ] Asynch NTP support 406 | - [ ] More code comments 407 | - [ ] Other? 408 | 409 | ## References 410 | 411 | - [LittleFS](https://arduino-esp8266.readthedocs.io/en/latest/filesystem.html) - Little File System 412 | - [BootStrap](https://getbootstrap.com/docs/3.4/) - BootStrap(3.4.1) - HTML, CSS, and JS framework 413 | - [jQuery](https://jquery.com/) - JS utility library 414 | - [OTA with Arduino IDE](https://arduino-esp8266.readthedocs.io/en/latest/ota_updates/readme.html#arduino-ide) - How to setup and config IDE for OTA updates 415 | - [Random Nerd Tutorials](https://randomnerdtutorials.com/) - Lots of good information on ESP8266 projects here 416 | 417 | ## Credits 418 | 419 | - Lots of great information and the webservices JS script in config.html is from [ESPixelStick](https://github.com/forkineye/ESPixelStick) 420 | -------------------------------------------------------------------------------- /data/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ESP8266 MyWidget - Config Page 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 41 | 42 |
43 |
44 |
45 |
46 |
Light Output
47 |
48 |
State1: Updating...
49 |

50 |
51 |
52 |
53 |
Image
54 |
55 |
C++ image
56 |
57 |
58 |
59 |
60 |
61 |
Device Configuration
62 |
63 |
64 |
65 | 66 |
67 | 68 |
69 |
70 |
71 | 72 |
73 | 74 |
75 |
76 |
77 | 78 |
79 | 80 |
81 |
82 |
83 | 84 |
85 | 86 |
87 |
88 |
89 |

90 |
91 |
92 |
93 |
Device Uptime
94 |
95 |
Updating...
96 |
97 |
98 |
99 |
100 |
101 |
Interrupt Speed
102 |
103 |
104 |
105 | 106 |
107 | 113 |
114 | 115 |
116 | 122 |
123 | 124 |
125 | 131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 | 141 | 142 | 143 | 144 | 145 | 459 | 460 | 461 | 462 | -------------------------------------------------------------------------------- /README.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

ESP8266-MyWidget

4 | 5 | This project can be used as a learning tool or as a template for starting a new ESP8266 project. 6 | It contains many of the components to build a ESP8266 project with web interface. 7 |
8 | This demo includes: 9 | 26 | 27 |

History

28 | 29 | I purchased several ESPixelSticks from Amazon for my synchronized LED Christmas light display. After using the ESPixelSticks, I became interested in how the ESP8266 worked and how to program it. So I began to review the ESPixelStick source code and the specifications of the ESP8266. It didn't take long to find out there is an add-on for the Arduino IDE that allows you to program the ESP8266 using the Arduino IDE and its programming language. A few years back, I had created some simple projects using Arduino UNO R3 and programmed using the Arduino IDE. Since I was already familiar with the Arduino IDE, I started by modifying some of the simple examples and playing with different libraries. I wasn't very interested in the low level hardware or interfacing to a sensor/module but I was more interested in an interactive UI and different ways to communicate with this device. I didn't have a particular project in mind so I created ESP8266-MyWidget; A project template for ESP8266.
30 |
31 | 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.
32 | 33 |

Requirements

34 | 35 | Along with the Arduino IDE, you'll need the following software to build this project:
36 | 40 | 41 | The following libraries are required:
42 | Extract the folder in each of these zip files and place it in the "library" folder under your arduino environment 43 | 49 | 50 |

Features

51 | 52 |

mDNS - multicast DNS

53 | 60 |

Web Services

61 | 142 | 143 |

Web Server

144 | 151 | 152 |

User Interface

153 | 181 | 182 |

HTTP API - GET and POST

183 | 184 | 456 | 457 |

File System

458 | 459 | This project is implmented using the LittleFS file system. All data is placed in a 'data' directory. 460 |
461 | Here is the directory and files associated with this project: 462 |
463 | 480 | If you modify a file locally, you must upload to device using Arduino ESP8266 LittleFS Filesystem Uploader. 481 |
482 | The LittleFS implementation for the ESP8266 supports filenames of up to 31 characters + terminating zero (i.e. char filename[32]), and as many subdirectories as space permits. 483 |
484 | Keep your filenames + directories names short! 485 | 486 |

MQTT (Message Queuing Telemetry Transport) - IoT messaging

487 | 488 | MQTT is implemented when a subscribe message is received, a corresponding publish message is sent. 489 | 490 |