PlatformIO Community

OTA wont work with platformIO/Atom but works with ArduinoIDE (No response from the ESP)

Hi there !
I try to make the OTA work with my Wemos mini lite.

Here is the error I get:

22:17:18 [DEBUG]: Options: {'esp_ip': '192.168.1.192', 'host_port': 26857, 'image': '.pioenvs/d1_mini_pro/firmware.bin', 'host_ip': '0.0.0.0', 'auth': '', 'esp_port': 8266, 'spiffs': False, 'debug': True, 'progress': True}
22:17:18 [INFO]: Starting on 0.0.0.0:26857
22:17:18 [INFO]: Upload size: 290272
Sending invitation to 192.168.1.192 ..........
22:17:28 [ERROR]: No response from the ESP
*** [upload] Error 1

My platformio.ini is:

[env:d1_mini_pro]
platform = espressif8266
board = d1_mini_lite
framework = arduino
upload_port = 192.168.1.192

My source code is a bit long to paste here, but it has:

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

in setup():

ArduinoOTA.setHostname("ESP_portail"); 
ArduinoOTA.begin(); 

in loop:

ArduinoOTA.handle();

Firewall was disabled and I copy paste my code in arduino IDE and OTA worked here !

Any idea ?

And you are sure, from outputs from your Wemos and/or your WiFi router, that the IP is correct?

1 Like

Yes I am :slight_smile:

I use static IP, inside my code.
I can see it on my router and I can ping it
and I can see it with an “arp” on my computer.

Hi!

I found the issue !!!

My sketch is very basic, it’s juste waiting to receive an MQTT message, and then blink the LED a couple of time if message is received.

The point is that I used an example from adafruit mqtt with:
while ( subscription = mqtt.readSubscription(5000)) {…

in case of no MQTT message arriving, it need 5sec before timeout.
I guess this may be too long to wait for OTA.

I reduced this to 1sec, and now OTA works fine !

I still wonder why arduino IDE was ok, while platformIO didnt succeed with 5sec.

it might be a longer timeout on arduino ?

Can we tune the OTA timeout (while waiting for device answer) in platformIO ?

As an unrelated note, you don’t have to use an ip to OTA the device.

If you use in your code…

ArduinoOTA.setHostname(“dufus”);

you can use

upload_port = dufus.local

Assuming mDNS or Bonjour has been loaded on your machine.

Hi !
I’m not sure why it would work with “hostname” but not with IP address ?

Regarding the timeout, you can tune it with following in your platformio.ini:
upload_flags = --timeout=20
but I was not able to find the unit of the number (it looks like 20 give 200sec on my side but…)

You may try several times (on my setup it does not always work on 1st trial)
I guess you already did, but in the past I had trouble with firewall enabled on my laptop…

Best regards,

I have used IP numbers in the past. I do not know why that would not work for you.

Timeout upload flag doesn’t work anymore. You have to edit sock2.settimeout(10) in espota.py

You mean this file? Does PIO have an older version of that?

PIO has the same version. You have to edit line 104.

I actually can’t see that flag having ever worked with espota, as it doesn’t have a timeout parameter, and doesn’t look like it did (going back to the code from four years ago, anyway). Editing the sock2.settimeout(10) variables in espota.py seems to be the only way to extend the timeouts.

There is the timeoute flag in the doc.

That’s because the instructions are wrong… that’s the output for the ESP32 version of the espota tool, from when a common version was used, instead of the platform specific version. I’ve done PRs to fix that up (espressif8266 espota, espressif32 espota).

i.e. ESP8266 version (source):

C:\Users\Peter\.platformio\packages\framework-arduinoespressif8266\tools>espota.py -h
Usage: espota.py [options]

Transmit image over the air to the esp8266 module with OTA support.

Options:
  -h, --help            show this help message and exit

  Destination:
    -i ESP_IP, --ip=ESP_IP
                        ESP8266 IP Address.
    -I HOST_IP, --host_ip=HOST_IP
                        Host IP Address.
    -p ESP_PORT, --port=ESP_PORT
                        ESP8266 ota Port. Default 8266
    -P HOST_PORT, --host_port=HOST_PORT
                        Host server ota Port. Default random 10000-60000

  Authentication:
    -a AUTH, --auth=AUTH
                        Set authentication password.

  Image:
    -f FILE, --file=FILE
                        Image file.
    -s, --spiffs        Use this option to transmit a SPIFFS image and do not
                        flash the module.

  Output:
    -d, --debug         Show debug output. And override loglevel with debug.
    -r, --progress      Show progress output. Does not work for ArduinoIDE

ESP32 version (source):

C:\Users\Peter\.platformio\packages\framework-arduinoespressif32\tools>espota.py -h
Usage: espota.py [options]

Transmit image over the air to the esp32 module with OTA support.

Options:
  -h, --help            show this help message and exit

  Destination:
    -i ESP_IP, --ip=ESP_IP
                        ESP32 IP Address.
    -I HOST_IP, --host_ip=HOST_IP
                        Host IP Address.
    -p ESP_PORT, --port=ESP_PORT
                        ESP32 ota Port. Default 3232
    -P HOST_PORT, --host_port=HOST_PORT
                        Host server ota Port. Default random 10000-60000

  Authentication:
    -a AUTH, --auth=AUTH
                        Set authentication password.

  Image:
    -f FILE, --file=FILE
                        Image file.
    -s, --spiffs        Use this option to transmit a SPIFFS image and do not
                        flash the module.

  Output:
    -d, --debug         Show debug output. And override loglevel with debug.
    -r, --progress      Show progress output. Does not work for ArduinoIDE
    -t TIMEOUT, --timeout=TIMEOUT
                        Timeout to wait for the ESP32 to accept invitation