ESP32 OTA updates using http/https

Enfield Cat's Blog: Arduino and other projects.


Project Location...

GitHub Reference: https://github.com/enfieldcat/ota_updater

Why use Over The Air (OTA) Updates?

Having a board tethered to your workstation is generally fine while you are developing and debugging your code. But what if after having installed a number of units in inaccessible places you find some bug that causes your IOT gadget to stop working every new moon? You could visit each unit with your laptop and update it. ...OR... you could use an OTA update to flash it remotely.

The standard Arduino OTA examples imply that you would need to have your Arduino IDE running in order to perform the update. That sounds OK if you only have a few units to update and they are on the same TCP/IP subnet as your IDE. So lets investigate an option where you just download your compiled code to a web server (say in the cloud), and your IOT gadgets can update themselves even if they are 100 miles away.

How OTA works for ESP32

The ESP32 typically will have 4 megabytes of EEPROM, and this is partitioned into segments. The fist 64k is used to hold boot information, partition table and nvram settings. Executable code should always be placed to start on a 64k boundary. So the remaining memory is typically then split into 2 OTA partitions and a SPIFFS filesystem. When you flash your ESP32 from the IDE the code is written into the first OTA partition. This leaves the second partition open to receive a code update while the running code continues to operate out of the first. The update process in brief description works as follows:

Prepare web server

Include ota_updater code in your Arduino sketch

Further considerations




Thank you for visiting camelthorn.cloudHome