Problems with ESP32 OTA Programming

Hi there!

For a device directly connected to the 230V AC line I need a way to program it Over-The-Air. For starters I created a new ESP32 / Arduino project using the example file in (Windows 10) c:\Users\Peter.platformio\packages\framework-arduinoespressif32\libraries\ArduinoOTA\examples\BasicOTA\BasicOTA.ino. It compiled fine and was loaded to my Espressif DevKit-clone.via USB - no problem. Then I reconfigured the platformio.ini file to this
platform = espressif32
board = esp32dev
framework = arduino
upload_protocol = espota
upload_port =

Now the compilation & linking works the same, but uploading stops with this:

14:55:56 [INFO]: Starting on
14:55:56 [INFO]: Upload size: 745360
Sending invitation to
14:55:57 [INFO]: Waiting for device…
14:56:07 [ERROR]: No response from device
*** [upload] Error 1

The router sees the device on the address The monitor confirms the IP-address when starting up. And by the way: The OTA procedure works fine using the Arduino IDE.

I did look at the various posts by mikemoy, facingtomorrow, Tom71238, autoroutedusud et al, but no solution solved my problem. So I am a bit at the end of my wits and hope for you guys to help me getting the thing to work. Thanks in advance!


And you’re in he same network as the ESP32? Can you ping on the commandline?

Also, maybe the OTA logic is on a different port? Try adding

upload_flags =

The only other thing I can recommend is recompiling the BasicOTA.ino sketch in PlatformIO with additionally logging set to verbose and flash it via serial. Then look what the ESP32 outputs over serial when you’re then trying to flash it via OTA.

Yes, I can. The answer comes within a few milliseconds.

Following your valuable suggestions I made a build clean, added “build_flags = -DCORE_DEBUG_LEVEL=5” to platformio.ini, rebuilt the project and uploaded the binary via USB, Everything worked fine.

Then I edited platformio.ini to
platform = espressif32
board = esp32dev
framework = arduino
build_flags = -DCORE_DEBUG_LEVEL=5
upload_protocol = espota
upload_port =
upload_flags =
** --port=3232**
and tried another upload, this time over the air. The error message “No response from device” was still there. :face_with_raised_eyebrow:

And did the device output anything over the serial port why you did that?

Oh, I probably have to mention, that you therefor need to have another serial montiro open all the time, otherwise the OTA upload output will overshadow the monitor output…

You can e.g. use PuTTY or hterm to open the serial port at 115200 baud (and line ending set to NL if using hterm).

Brilliant idea! This is what hterm said:
[D][Updater.cpp:136] begin(): OTA Partition: app1
Start updating sketch
Progress: 0%
[E][WiFiClient.cpp:258] connect(): socket error on fd 57, errno: 113, “Software caused connection abort”
Error[2]: Connect Failed
[E][Updater.cpp:264] end(): premature end: res:0, pos:0/748368

Scratching my head, does it reveal a clue about the reason of the failure?

Can you show the exact ESP32 model you’re working with? There might be a mismatch regarding flash size e.g…

Otherwise this

Looks like the client / PC side might be doing something wrong, too.

Is any antivirus software installed with a firewall that might interfere here? Or, at the router?

Does programming via OTA work via Arduino IDE?

Another thing you can do to get more output is to use the project task “Advanced -> Verbose Upload”. Maybe that makes espota output more info during upload.

maxgerhardt, you did it! :smiley:

I am using Microsoft Defender within a Private Network. When I switch the firewall off, the OTA-upload works perfectly. So we have a usable workaround. But indeed I would not want to switch off the firewall permanently, and doing so each time I want to upload OTA is a bit cumbersome.

And now we are getting a bit off-topic, i.e. off-platformio, but I do esteem your support even more:

It is an ESP32-WROOM-32D, 1st generation with 4MB flash IIRC.

Yes, it does with these settings:

Well if it works in Arduino IDE then then somehow that’s not being blocked o_O.

I’d advise to maybe add an exception to the firewall to let C:\Users\Max\.platformio\packages\framework-arduinoespressif32\tools\ or python.exe communicate freely.

I did as you suggested, and after some trial and error the problem is now solved to my satisfaction. This is what I did:

  • In the Windows Settings (<Windows> + i) navigate through Update & Security --> Windows Security --> Firewall & network protection --> Allow an App through firewall
  • Change settings
  • Check the line(s) for python.exe. In my environment there were two of them. One of them did enable OTA uploading.

There seems no way to allow just one specific python-script to pass the firewall. But the remaining risk seems to be acceptable.

So there we are. Thanks a lot, maxgerhardt for your very rapid and expert help. :clap: