Homie for ESP8266 supports OTA, if enabled in the configuration, and if a compatible OTA server is set up.
It works this way:
- The device receives an OTA notification from the MQTT broker, as defined in the Homie convention. If the version sent by the broker is different from the one set with
Homie.setFirmware(), and if OTA is enabled in the configuration, the device will be flagged to reboot to
OTAmode as soon as the device will be resettable (with
- The device boots in
- The device reaches the OTA server and attempt to flash the new firmware
- If the OTA fails or succeed, the device reboots to
Creating a compatible OTA server¶
OTA mode, the device sends a request to the host/path set in the configuration. This request contains the following headers:
x-ESP8266-free-space: space available on the ESP8266 in bytes
OTA version target(e.g.
Your server has to parse these headers. Based on the
x-ESP8266-version header, it should decide what firmware it should send to the device. If no firmware is found, or if the firmware is bigger than the
x-ESP8266-free-space header content, you can abort the OTA by sending a response with a
304 error code. To actually send the firmware, you must transfer the firmware file with a
200 code. For more bulletproof updates, you can also provide in the response the MD5 of your firmware file, in the
You have an example PHP in the Arduino for ESP8266 doc and a Node.js example in the homie-server project.