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()
{
Serial.begin(115200);
// Connect to Wifi
Serial.println("Connecting to wifi");
delay(20);
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED)
{
Serial.println("Wifi onnection Failed!");
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
Serial.print("MAC address: ");
Serial.println(WiFi.macAddress());
// 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
ArduinoOTA.handle();
}
And this is my platformio.ini:
[env]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200
lib_deps =
jandrassy/ArduinoOTA @ ^1.1.0
[env:usb]
upload_protocol = esptool
upload_port = /dev/ttyUSB*
[env:ota]
upload_protocol = espota
upload_port = 192.168.178.133
upload_flags =
--auth=test
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
SSID: …
IP address: 192.168.178.133
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’: ‘192.168.178.133’, ‘host_ip’: ‘0.0.0.0’, ‘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 0.0.0.0:41596
21:05:23 [INFO]: Upload size: 755472
Sending invitation to 192.168.178.133 …
21:07:03 [ERROR]: No response from the ESP
*** [upload] Error 1
======================
Why isn’t this working? Can anyone spot the mistake?
Thanks ![]()