OTA Upload does not work with ESP32

I’m desperately trying to get OTA uploading to work on PlatformIO and my ESP32. Here’s the code I’m currently using:

#include <Arduino.h>
#include <WiFi.h>
#include <esp_wifi.h>
#include <ArduinoOTA.h>

#define WIFI_SSID "..."
#define WIFI_PASS "..."

void setup()
  // Connect to Wifi
  Serial.println("Connecting to wifi");
  while (WiFi.status() != WL_CONNECTED)
    Serial.println("Wifi onnection Failed!");
  Serial.println("WiFi connected");
  Serial.print("SSID: ");
  Serial.print("IP address: ");
  Serial.print("MAC address: ");

  // OTA Configiration and Enable OTA
  Serial.println("Starting OTA server");
  ArduinoOTA.begin(WiFi.localIP(), "Test", "test", InternalStorage);

  // Done
  Serial.println("OTA started successfully");
  Serial.println("Waiting for upload...");

void loop()
  // OTA Handle

And this is my platformio.ini:

platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200
lib_deps =
  jandrassy/ArduinoOTA @ ^1.1.0

upload_protocol = esptool
upload_port = /dev/ttyUSB*

upload_protocol = espota
upload_port =
upload_flags =

After uploading via USB I get the expected output from the serial monitor:

Connecting to wifi
Wifi onnection Failed!
Wifi onnection Failed!
Wifi onnection Failed!
WiFi connected
IP address:
MAC address: 84:0D:8E:1C:F3:44
Starting OTA server
OTA started successfully
Waiting for upload…

But now comes the problem: when uploading the code again via OTA, it does not work at all.
Here’s the output:

Configuring upload protocol…
AVAILABLE: cmsis-dap, esp-bridge, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Uploading .pio/build/ota/firmware.bin
21:05:23 [DEBUG]: Options: {‘esp_ip’: ‘’, ‘host_ip’: ‘’, ‘esp_port’: 3232, ‘host_port’: 41596, ‘auth’: ‘’, ‘image’: ‘.pio/build/ota/firmware.bin’, ‘spiffs’: False, ‘debug’: True, ‘progress’: True, ‘timeout’: 10}
21:05:23 [INFO]: Starting on
21:05:23 [INFO]: Upload size: 755472
Sending invitation to …
21:07:03 [ERROR]: No response from the ESP
*** [upload] Error 1

Why isn’t this working? Can anyone spot the mistake?
Thanks :slight_smile:

Why not using the built-in ArduinoOTA library?

This is the library that comes up when searching for “ArduinoOTA” in the PlatformIO library manager.

I thought there was only one ArduinoOTA library? If not, where can I find this built-in library?

It is built-in. Simply `#include <ArduinoOTA.h>

See one of the examples from the link above.
That is the built-in library.

Remove the lib_deps and perform a clean.

1 Like

To say it more clearly: You’re completely mismatching the OTA library code running on the ESP32 and the desktop program trying to upload to it. The espota tool expects the ESP32 to be running the builtin ArduinoOTA library that’s in Arduino-ESP32. Start with the https://github.com/espressif/arduino-esp32/blob/2.0.16/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino example, just adapting your SSID and password, and the IP in the platformio.ini.

The documentation tells you to do the same, linking to BasicOTA.