Skip to content

070. OTA update

Reivaxy edited this page Sep 15, 2019 · 1 revision

OTA Update: update a module wirelessly

The esp8266 board you use in your modules may not be easily accessible, it can even be soldered, and if you use the most basic ones, they do not have a TTL Serial interface to connect to.

This is why the OTA update is very convenient: you can upload a new version of an agent module firmware wirelessly.

Requirements

You need the Arduino IDE to compile and upload the new version. You need to install python version 2.7.x (not 3.x) on your system. If you are using Windows, make sure to check the "Add python.exe to Path" since it's not checked by default.

How to

Set up the IDE

In the Arduino IDE, select the right board type to match the module you want to update. Pay attention to the memory settings. If you are using ESP-01 boards, you'll be able to use OTA only if they are equipped with at least 1MB of memory. Some come with only 512K, so you need to check the memory chip.

25Q40 is 512K, while 25Q80 is 1MB, 25Q16 is 2MB, etc. For an ESP01 board equipped with 25Q80, select the "1MB no SPIFFS" memory setting.

BEWARE: OTA will only work if the module was originally (not using OTA) flashed with the correct memory setting!

Make sure the code compiles fine.

Start OTA on the target agent module

This is not yet exposed in the UI so you'll have to use a REST client (like POSTMAN): If you don't know the agent IP address on the wifi network opened by the master module, make a GET on /api/list to get the list of modules. (Also, for now, the IP of each module is also displayed on the UI, in the footer of the module container).

Then make a POST request to the master API on /api/ota, providing the target agent module IP in the Xiot-forward-to header.

The target module with then disconnect from the master wifi network, to connect to your home network. Its display will show the new IP address, and a message saying it's ready for OTA.

Upload the new version

In the IDE, click on "Tools/port", and you should see the newly opened wifi port. You may need to restart the IDE to see the wifi port show up in the PORT list. Select it, then hit upload.

The module will display the upload progression.

Once uploaded successfully, the new code will replace the old one, and the module will restart. If you updated the configuration version number, the agent will be reset to 'factory' defaults and try to connect to the default wifi network, so you will need to restart the master module to expose this default wifi network.

And that's it!