ArduinoOTA ESP32: Wi-Fi (OTA) Wireless Update from the Arduino IDE

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on email
Share on whatsapp
Table of Contents
drapeau france
level advanced
esp32 geekcreit wroom

The ArduinoOTA library for wireless updates (OTA) in Wi-Fi is also compatible with ESP32266, the ESP32266’s more powerful successor. It is integrated into the Arduino Core for ESP32 developed by Espressif (GitHub page of the project). It is not yet possible to install the development kit from the board manager. Since the SDK is still in development, the installation process depends on the machine on which the Arduino IDE is installed. It is now possible to use the password hash to further secure the remote update. Another novelty, it is now possible to update in Wi-Fi the SPIFFS memory area.

Install the ArduinoOTA library for ESP32 on the Arduino IDE

Before starting the installation, exit the Arduino IDE. Then, to install the development kit on your MacOS, Windows, Linux or Raspberry Pi, follow this previous tutorial. Once the SDK is installed, you can restart the IDE.

If everything went smoothly, you must have new ESP32 boards

esp32 board cartes ide arduino windows 10 64-bits

In the current version, the kit supports generic boards (ESP32 Dev Module up to 4MB), and several manufacturers’ boards known as the new Wemos LoLin32 presented recently.

Flash memoryUSB-Serial
SparkFun ESP32 ThingSparkFun ESP32 Thing4MB
Electronic SweetPeas - ESP320Electronic SweetPeas – ESP32016MB ?
Nano32 de MakerAsia4MB
wemos lolin32WEMOS LoLin324MB
espea32 esp32ESPea32 available on Tindie4MBCP2104
Noduino Quantum esp32Noduino Quantum16MBCP2102
node32s esp32 development boardNode32s4MB
Hornbill ESP32 DevHornbill ESP32 Dev4MB
hornbill esp32 minimaHornbill ESP32 Minima4MB
IntoRobot Fig4MB

To bring up the sample menu, select your ESP32. Generic boards are very well supported by the SDK. From the menu, select the example basicOTA.

arduinoota esp32 1 exemple basicota

The code differs very little from that of the ESP8266 boards.

#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

const char* ssid = "..........";
const char* password = "..........";

void setup() {
  WiFi.begin(ssid, password);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! Rebooting...");

  // Port defaults to 3232
  // ArduinoOTA.setPort(3232);

  // Hostname defaults to esp3232-[MAC]
  ArduinoOTA.setHostname("Demo OTA ESP32");

  // No authentication by default
  // ArduinoOTA.setPassword("admin");

  // Password can be set with it's md5 value as well
  // MD5(admin) = 21232f297a57a5a743894a0e4a801fc3

  ArduinoOTA.onStart([]() {
    String type;
    if (ArduinoOTA.getCommand() == U_FLASH)
      type = "sketch";
    else // U_SPIFFS
      type = "filesystem";

    // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
    Serial.println("Start updating " + type);
  ArduinoOTA.onEnd([]() {
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
    else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
    else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
    else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
    else if (error == OTA_END_ERROR) Serial.println("End Failed");
  Serial.print("IP address: ");

void loop() {

Several parameters are available:

  • 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 ESP32. This machine name will be broadcast over the network and retrieved by the Arduino IDE. 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.
  • SetPasswordHash: allows you to store the password fingerprint for added security. See below to learn how.

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

  • OnStart: The code to be executed when the update is started. New on the ESP32, it is possible to remotely update the files of the zone SPIFFS. This is very handy if you need to develop an HTML interface for your project.
  • OnEnd: idem at the end
  • OnProgress: during the progress
  • OnError: and on error

At the end of the setup, the wireless update support is started by calling the begin () method.

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

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

Secure the update with the hash of the password

The ESP32 is much more secure than the ESP8266 (read this article for more information), it is possible to store the hash of the password in place of it. To create your password fingerprint, you can use an online generator such as this one. For example, the hash of the admin password will give the fingerprint 21232f297a57a5a743894a0e4a801fc3.

Please note that some online generators are not recommended … Do not use the admin password!

arduinoota esp32 2 hash password md5 online generator

Then, use the setPasswordhash function instead of setPassword () to specify the authentication password.


Wireless Update Test

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

arduinoota esp32 6 serial monitor 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 esp32 1 ide arduino

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 esp32 3 password authentication

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

arduinoota esp32 5 wireless upload update ide arduino

The SDK is still in development. During the tests, I had to enter the password twice before successfully updating.

WEMOS WiFi & Bluetooth Batterie ESP32 développement outil ESP32 batterie esp8266 ESP WROOM 32 ESP32

Price: CHF 6.56
as of 21 September 2021 3 h 01 min
Wait For A Price Drop

Price History


Current Price CHF 6.5621 September 2021
Highest PriceCHF 6.5621 September 2021
Lowest PriceCHF 5.6621 December 2020
Since 23 September 2020

Last price changes

CHF 6.5621 September 2021
CHF 6.4716 September 2021
CHF 6.4513 September 2021
CHF 6.4810 September 2021
CHF 6.434 September 2021
Click to rate this post!
[Total: 0 Average: 0]

Thanks for your reading

Did you like this project ? Don't miss any more projects by subscribing to our weekly newsletter!

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on email
Share on whatsapp

Are you having a problem with this topic?

Maybe someone has already found the solution, visit the forum before asking your question
1 Comment
  1. Hi, Can you please share how the ESP32 is wired up and connected, thanks

    Leave a Reply

    Read more
    Recent posts on the Forum
    DIY Projects
    DIY Projects
    %d bloggers like this: