Homie for ESP8266 supports OTA, if enabled in the configuration, and if a compatible OTA server is set up.

It works this way:

  1. 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 OTA mode as soon as the device will be resettable (with Homie.setResettable()).
  2. The device boots in OTA mode
  3. The device reaches the OTA server and attempt to flash the new firmware
  4. If the OTA fails or succeed, the device reboots to normal mode

Creating a compatible OTA server

In OTA mode, the device sends a request to the host/path set in the configuration. This request contains the following headers:

  • User-Agent: ESP8266-http-Update
  • x-ESP8266-free-space: space available on the ESP8266 in bytes
  • x-ESP8266-version: Device ID=Firmware name=Firmware version=OTA version target (e.g. c631f278=awesome-light=1.0.0=1.1.0)

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 x-MD5 header.

You have an example PHP in the Arduino for ESP8266 doc and a Node.js example in the homie-server project.