PlatformIO OTA Problem

I have a problem trying to upload cpp code to my Wemos D1 mini using OTA in VSC.

I have used OTA in Arduino IDE for some time & that works fine.

When trying the same thing in in VSC the program says

Uploading 1-100%
Done
Waiting for Result
Result OK

BUT after that the Wemos will not boot, so it seems as if something is wrong or incomplete with the upload…

The software is just cut and paste from Arduino IDE, where it works,
(and works fine in VSC when uploaded via COM Port)…

PLATFORMIO.INI:

[env:d1_mini]

platform = espressif8266
board = d1_mini

framework = arduino
;upload_port = COM[5]

upload_port = 192.168.0.16
;monitor_speed = 115200
;monitor_port = COM5
upload_protocol = espota
;each upload flag in a new line
;upload_flags =
; --auth=xxxxxx

Here is part of the output

DATA:    [===       ]  34.2% (used 28000 bytes from 81920 bytes)
PROGRAM: [===       ]  34.7% (used 361996 bytes from 1044464 bytes)
Creating BIN file ".pio\build\d1_mini\firmware.bin" using ".pio\build\d1_mini\firmware.elf"
Configuring upload protocol...
AVAILABLE: espota, esptool
CURRENT: upload_protocol = espota
Uploading .pio\build\d1_mini\firmware.bin
14:40:11 [DEBUG]: Options: {'esp_ip': '192.168.0.16', 'host_ip': '0.0.0.0', 'esp_port': 8266, 'host_port': 21106, 'auth': '', 'image': '.pio\\build\\d1_mini\\firmware.bin', 'spiffs': False, 'debug': True, 'progress': True}
14:40:11 [INFO]: Starting on 0.0.0.0:21106
14:40:11 [INFO]: Upload size: 366144
14:40:11 [INFO]: Sending invitation to: 192.168.0.16
14:40:11 [INFO]: Waiting for device...

Uploading: [                                                            ] 0%
Uploading: [                                                            ] 0% 
Uploading: [                                                            ] 0%
Uploading: [=                                                           ] 1% 

(etc. etc. continues to 100%)...

Uploading: [============================================================] 99% 
Uploading: [============================================================] 99% 
Uploading: [============================================================] 100% Done...

14:40:23 [INFO]: Waiting for result...
14:40:23 [INFO]: Result: OK

When I change the platformio.ini to enable upload via cable (COM5) instead of via IP, it uploads ok, reboots and everything works fine, (but unfortunately not via IP-address/OTA)…

Any ideas ??

What sort of debuggging have you done for this so far? Have you tried going back to the BasicOTA example sketch, and seeing if that works with the necessary change to WiFi SSID and password? Is the device actually booting - is there any serial debug messages being output? What is the bootloader output (serial baud 74800) when the esp8266 starts up after OTA programming?

The fact you said it worked when you programmed via serial, and it worked then but with no IP/OTA sounds odd… no response from the device if you ping it via the command line?

For me, I can’t say I’ve had any issues with OTA and PIO (that weren’t self-inflicted :laughing:) … something like this works just fine for me… but I can’t see anything wrong in your config.

[env]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps =
    126 ; FastLED
    567 ; WifiManager
monitor_port = /dev/ttyUSB0
monitor_speed = 115200

[env:d1mini-serial]
upload_port = /dev/ttyUSB0

[env:d1mini-OTA]
upload_protocol = espota
upload_port = DownstairsLightController.local
1 Like