ESP8266 OTA Firmware Upgrade Manager Flow

567 views
Skip to first unread message

Dean Cording

unread,
Jul 30, 2016, 6:15:10 AM7/30/16
to Node-RED

I've been playing around with some ESP8266 modules which are these very cheap microcontroller modules with built in WiFi.  They are ideal for distributed sensor networks where they feed data in from one-wire or I2C sensors to MQTT over a WiFi connection.  There are a few different firmware coding environments available but the one I have been using is the Arduino based one.  A really cool feature of this firmware environment is its support for Over The Air firmware updates.  That is, you can update the firmware on the module remotely over WiFi.


I have written a Node Red flow that provides a tool for managing Over The Air firmware updates.


The ESP8266 OTA upgrade library contacts a specified URL and passes the name and MD5 hash of the module's current firmware. This server implemented in this flow will compare the supplied MD5 hash against the one for the latest firmware and, if different, send the new firmware to the module. The server will uses either the module's MAC address or firmware name to identify the correct firmware file to send.


This flow also includes a firmware management screen for uploading new firmware files, deleting firmware files, and creating symbolic links to existing firmware files. Symbolic links allow you to point a specific MAC address to a firmware file so as to be able to replace the firmware on a module with a completely different one.  The firmware manager is accessed from http://your.node-red.server:1880/esp8266-ota


A template for producing firmware with OTA upgrade support built in is available from this gist. This template checks for a firmware update on each boot up. It then runs a process such as reading a sensor and publishing the value, before entering a power saving deep sleep. When it wakes, it will check for a firmware upgrade again and repeat the cycle.



Enjoy


Dean

Walter Kraembring

unread,
Jul 30, 2016, 7:42:10 AM7/30/16
to Node-RED
Wow, that it clever,

I need to start looking at those ESP modules, currently I am just having z-wave, wired 1-wire and 433 MHz RF stuff in the house. Having those ESP instead sounds attractive. What about power supplying, is it possible to run them with typical 3V Lithium batteries for a longer period (a couple of years)?

Dean Cording

unread,
Jul 30, 2016, 8:38:24 AM7/30/16
to Node-RED
They are a 3V chip so ideally suited to lithium batteries.  The deep sleep current draw is about 20uA.  I'm planning on a sensor that wakes every 15 minutes and by my calculations it should run on a pair of alkaline D cells for about 400 days.

The ESP8266 is starting to show up in off the shelf controllers which are dirt cheap.

Peter Scargill

unread,
Jul 30, 2016, 9:15:45 AM7/30/16
to Node-RED
Or if you're not into Arduino - you could just use my ESP code and call the otaupgrade function from Node-Red via MQTT. As fpr running them for a couple of years on Lithium - they'd need to be pretty big Lithium batteries - they can't do WIFI while asleep. Solar panel topup? http://tech.scargill.net/blowing-the-home-control-2016-code/

Toshi Bass

unread,
Jul 30, 2016, 10:53:38 AM7/30/16
to Node-RED
I have slowly migrated from standard esp8266-12's to using wemos di mini's which are basically the same but with all the necessary components onboard already which makes life much easier and you can also get a battery shield as well as others.   http://www.aliexpress.com/store/1331105  

I also have a number of sonoff units 

I control the above with node-red via mqtt and node-red-contrib-blynk-websockets and program them using basic_OTA via arduino IDE which is easy and works very well, I tried other methods over time by there just to complicated,

I am not sure automatic firmware updates are for me, but I would "Enjoy"checking the "Node Red flow" you have written, but were to find it ? am I missing something !


Dave C-J

unread,
Jul 30, 2016, 11:47:51 AM7/30/16
to node...@googlegroups.com

Need big LiPos ? Just take apart an old laptop battery. (Carefully of course !) Usually only 1 or 2 cells are actually knackered and the rest can drive motes for ages. Often they are 16650 size cells... Much bigger than the wemos

Dean Cording

unread,
Jul 30, 2016, 5:52:04 PM7/30/16
to Node-RED
Its on the Node Red flows directory but I forgot to include the link http://flows.nodered.org/flow/888b4cd95250197eb429b2f40d188185

Dean
Reply all
Reply to author
Forward
0 new messages