Home | Difficulty level | Advanced | ArduinoOTA: Wireless Update (OTA) from the Arduino IDE of ESP8266 Programs

ArduinoOTA: Wireless Update (OTA) from the Arduino IDE of ESP8266 Programs

The ArduinoOTA library is a library that allows to update the Arduino program (and ESP3226, ESP32) wirelessly in Wi-Fi. It is an essential library when developing connected objects. It allows to update the program without having to disassemble the microcontroller (Arduino, ESP8266, ESP32) to connect it to his computer. This library was originally developed to update the Arduino programs, it is perfectly supported by the ESP8266 and ESP32. For this tutorial, we will only address the case of ESP8266.

Install the ArduinoOTA library for ESP8266 on the Arduino IDE

The ArduinoOTA library is integrated into the ESP8266 library. There is nothing more to install. If you’re new to ESP, here’s how to install the ESP library and support. Open the preferences (from the Arduino menu) and add to the list of packages this one

IDE Arduino 1.6.8 esp8266 package

Then go to the map manager and look for esp8266, then click install.

IDE Arduino 1.6.x ajouter carte esp8266

After installation, new examples have been added to the sample menu. Select your ESP8266 card to display the available samples. Open the BasicOTA example in the ArduinoOTA submenu

arduinoota 0 basicota example

This program contains everything you need to manage wireless upgrade in your ESP projects.

Before reversing the program, change the ssid variables (Wi-Fi network to which to connect) and password (password).

Here, the program uses the ESP8266WiFi library to connect to the network. You can also use the WiFiManager library presented earlier.

Once the connection is established, it is possible to define additional (optional) parameters:

  • SetPort: by default the communication port is 8266. It is not very useful to change it unless it is already in use. For example, for a project integrating UDP communication.
  • SetHostname: This is probably the most important option. It allows you to assign a name to the ESP8266. If you have a lot of objects on your network, it will be much easier to identify it by name than by an identifier built automatically from the serial number.
  • SetPassword: used to request a password from the Arduino IDE before running an update. Practice if you work at several or in a school.

There are four other ways to connect treatments in the following cases:

  • OnStart: code to run when the update is started
  • OnEnd: idem at the end
  • OnProgress: during the progress
  • OnError: and on error

You will not need to add treatments in most cases. In particular, these functions allow us to remain informed of the smooth running of operations.

At the end of the setup, once all functions have been defined, start the wireless update support by calling the begin () method.

Finally, for everything to work, it is necessary to call the ArduinoOTA.handle () method in the loop () loop.

Wireless Update Test

Upload the program and open the Terminal to verify that the ESP8266 is properly connected to the Wi-Fi network.

arduinoota 1 ide arduino ip address

The Arduino IDE automatically detects devices that support remote update. They are added to the list of ports in a new section called Network ports.

arduinoota 2 esp8266 wifi update wireless arduino code


It seems that version 1.8.x includes a bug that prevents the devices from updating. If your ESP does not appear a few seconds after starting the ESP, just restart the Arduino IDE.

To update the program, simply select the ESP as the port instead of the usual serial port. Then upload the program as usual. Here, as a password is required, an input window appears in the IDE. It is requested only once

arduinoota 5 saisie mot de passe type password ide arduino

The remote update (or failure) of the remote update can be tracked directly from the Arduino IDE.

arduinoota 4 ide arduino done uploading

It is not possible to open the serial monitor with wireless setup. A small Web interface is required. Read this tutorial to learn how to add a Web server and HTML interface to an ESP8266 project. To go further, here is a series of articles dealing with the subject

  • It is known long-lasting bug that Arduino IDE should be restarted to see the network devices which recently came online (it was present in 1.6.x and I guess in earlier versions as well).
    It’s a pity it is still not fixed in 1.8.x 🙁