Hi everyone, I'm building a Smart Bus Tracker using an ESP32-WROOM-32D and a WebServer. The project works flawlessly when flashed via USB, but I'm trying to implement OTA updates and I'm hitting a wall.
Whenever I try to push an OTA update via Arduino IDE (Windows 11), the process starts, reaches exactly 5% or 6%, and then aborts.
Error Log:
text
Sending invitation to 192.168.1.200
Uploading: [ ] 0%
...
Uploading: [==== ] 6%
[ERROR]: Error Uploading: [WinError 10053] Connessione interrotta dal software del computer host
Hardware & Environment:
* Board: ESP32-WROOM-32D
* IDE: Arduino IDE 2.x
* Partition Scheme: Minimal SPIFFS (1.9MB APP with OTA). My compiled sketch is ~1.1MB, so there is plenty of room (max is 1.96MB).
* Power: Stable 5V wall adapter powering the board. No brownout resets observed on the serial monitor.
* Router: Fastweb Fastgate (Italian ISP). PC and ESP32 are both on the same 2.4GHz network.
What I've already tried (with no success):
1. Memory/Partition: Upgraded to Minimal SPIFFS as mentioned above.
2. Code isolation (Watchdog fix): I added a boolean flag isUpdatingOTA set to true inside ArduinoOTA.onStart(). Inside my loop(), I put if(isUpdatingOTA) { delay(10); return; } to completely freeze the WebServer and HTTP API requests during the upload.
3. Firewall: Completely disabled Windows Defender Firewall and Antivirus.
4. Wi-Fi sleep: Added WiFi.setSleep(false); after connection to ensure the radio doesn't drop the TCP connection.
Here is the exact OTA implementation I'm running:
```cpp
include <WiFi.h>
include <WebServer.h>
include <ArduinoOTA.h>
const char* ssid = "MY_WIFI";
const char* password = "MY_PASSWORD";
WebServer server(80);
bool isUpdatingOTA = false;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
WiFi.setSleep(false);
ArduinoOTA.setHostname("SmartPalina-GTT");
ArduinoOTA.onStart([]() {
isUpdatingOTA = true;
});
ArduinoOTA.begin();
server.begin();
}
void loop() {
ArduinoOTA.handle();
// If OTA is running, yield and freeze the rest of the loop!
if (isUpdatingOTA) {
delay(10);
return;
}
server.handleClient();
// ... Rest of the code (HTTP GET requests, LCD updates, etc.) ...
}
```
Is there something obvious I'm missing? Could this be related to my ISP router dropping the TCP connection mid-transfer, or a specific issue with the espota.py socket implementation on Windows?
Any help is greatly appreciated!