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.

1 Like

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

I have the same message error

19:45:19 [DEBUG]: Options: {ā€˜esp_ipā€™: ā€˜192.168.2.59ā€™, ā€˜host_ipā€™: ā€˜0.0.0.0ā€™, ā€˜esp_portā€™: 3232, ā€˜host_portā€™: 59186, ā€˜authā€™: ā€˜ā€™, ā€˜imageā€™: ā€˜.pio\build\Gateway_59\firmware.binā€™, ā€˜spiffsā€™: False, ā€˜debugā€™: True, ā€˜progressā€™: True, ā€˜timeoutā€™: 10}
19:45:19 [INFO]: Starting on 0.0.0.0:59186
19:45:19 [INFO]: Upload size: 1029536
Sending invitation to 192.168.2.59 ā€¦
19:46:59 [ERROR]: No response from the ESP
*** [upload] Error 1

But I canā€™t ping the IP address 192.168.2.59

Do you know how I can fix it?

Thanks

I SOLVED

Problem with Firewall. I have given permisions to Visual Studio Code to use ports.

THANKS

2 Likes

Is that can or canā€™t ping that IP Address? If itā€™s canā€™t, you may have bigger problems, as that would suggest the device isnā€™t connected to you wifi, or responding to connections, hence the upload error is correct since the device isnā€™t responding.

still having the exact same issue of the opener once upgraded to the latest platformio coreā€¦
is it a timeout problem?
I can do OTA with Arduino IDE no problem.