OTA programming Arduino Uno with ESP8266 via WiFi

Hi,

I'm attempting to upload sketches onto my Uno with an ESP8266 shield wirelessly. Currently, I'm able to flash sketches on the ESP8266 shield OTA (using ArduinoOTA.h) and have it communicate with the Arduino Uno through serial (SoftwareSerial). This way, I could maximise the use of both MCUs as there are many features I would like them to have (at once, such as LCD, buttons, sensory algorithms).

However, I could not find a way to upload sketches onto my Uno through the ESP8266 shield. If possible, I'm looking into protocols like SPI or even serial (SoftwareSerial) for this purpose. May I know if there's a way to do so?

Recap: PC ->(WiFi OTA programming) ESP8266 shield ->(SPI/Serial programming??) Uno

PS: I could just use an ESP32, but due to various constraints, I wish to achieve the task with just an Uno and ESP8266 shield.

Cytron ESP8266 WiFi Shield (ESP8266 shield with ESP-Wroom-02 module)

for SPI there is ESP8266AVRISP library. it is the OTA version of "Arduino as ISP"

Thanks for your reply. I have tried the example .ino given in the ESP8266AVRISP library.

Porting the code over to platformio, I then added a few lines of codes to enable ArduinoOTA. However, when I attempted to do "Upload using Programmer", it gave me this error:

avrdude: Error: Invalid -P value: '192.168.1.32'
         Use -P usb:bus:device

avrdude done.  Thank you.

Below is my platformio.ini file:

[env:uno]
platform = atmelavr
framework = arduino
board = uno

upload_protocol = arduinoisp
; each flag in a new line
upload_flags =
    -P$UPLOAD_PORT
    -b$UPLOAD_SPEED

; edit these lines
upload_port = 192.168.1.32
upload_speed = 19200

Sorry if it may seem a bit confusing, pardon my inexperience in dealing with ISP programming. But I could really use some help on this...

did you try the example of the library? you should upload to network port

I've tried this example Arduino/Arduino_Wifi_AVRISP.ino at master · esp8266/Arduino · GitHub

And I've tried to upload to network port as shown in the platform.ini file:

"upload_port = 192.168.1.32"

It worked with my previous attempts without the ESP8266AVRISP library...

seanyeots:
I've tried this example Arduino/libraries/ESP8266AVRISP/examples/Arduino_Wifi_AVRISP/Arduino_Wifi_AVRISP.ino at master · esp8266/Arduino · GitHub

And I've tried to upload to network port as shown in the platform.ini file:

"upload_port = 192.168.1.32"

It worked with my previous attempts without the ESP8266AVRISP library...

the port should be in Port menu in Tools menu as for the esp8266 arduino, but with a different name

Thanks, I have found the solution to the issue. The correction I made in platformio.ini file goes like this:

[env:uno]
platform = atmelavr
framework = arduino
board = uno

upload_protocol = stk500v1
; upload_protocol = arduinoisp

; each flag in a new line
upload_flags =
    -P$UPLOAD_PORT
    -b$UPLOAD_SPEED

; edit these lines
upload_port = net:192.168.1.32:328
upload_speed = 19200

Notice the port I used is in the format of "net:IP_ADDR:PORT_NUM", with the protocol as "stk500v1".

here are some instruction for ESP8266AVRISP as integrated in WiFiSpiESP firmware

other option to upload over esp8266 to AVR MCU is over telnet and Serial bootloader.
but it works only with Linux version of avrdude