OTA ESP32-S2-Saola

ESP32S2 support isn’t even yet mainstream in PlatformIO yet, only user-written platform modifications are available that allow this. See Support for the latest Arduino v2.0 · Issue #619 · platformio/platform-espressif32 · GitHub.

As already discussed in Fatal error: Adafruit_NeoPixel.h: No such file - #2 by maxgerhardt for ESP32-C3 chips, you can use for a ESP32-S2 chip…

; global settings
[env]
platform = https://github.com/Jason2866/platform-espressif32.git
board = esp32-s2-saola-1
framework = arduino
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git

; environment with no modifications for USB-based upload
[env:esp32-s2-saola-1]

; environment for OTA upload
[env:esp32-s2-saola-1-ota]
upload_protocol = espota
; use IP here or <mDNS_NAME>.local
upload_port = 192.168.0.255

This will give you two environments, one for USB-serial upload and one for OTA upload.

and src/main.cpp from arduino-esp32/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino at master · espressif/arduino-esp32 · GitHub.

You need to select a partition table that has an app0 and app1 partition at least. This is already explained in Espressif 32 — PlatformIO latest documentation. However, since the default table is default.csv which has the needed partitions, no modification is needed. Unless you want to actively choose a different partition with bigger possible application sizes of course, like min_spiffs.csv.

This is already explained in Espressif 32 — PlatformIO latest documentation. Initially of course via the USB cable, then after an appropriate sketch is upload that allows OTA uplaod (like the one shown above), via OTA.

This is inferrable by looking at the library code arduino-esp32/libraries/ArduinoOTA at master · espressif/arduino-esp32 · GitHub.

As you can read in

it opens a UDP port which is always listened for as long as the device has internet connectivity. It also advertisies its hostname using MDNS.