ESP32 BASICS · LESSON 19
Over-the-Air (OTA) Firmware Updates
Reflashing a deployed ESP32 over Wi-Fi instead of walking back to it with a USB cable.
A device that's already deployed — bolted to a wall, buried in an enclosure — is inconvenient to reach with a USB cable every time firmware needs updating. OTA (over-the-air) updates push new firmware over Wi-Fi instead.
ota_basic.ino
#include
#include
void setup() {
WiFi.begin("your-network-name", "your-network-password");
while (WiFi.status() != WL_CONNECTED) delay(300);
ArduinoOTA.setHostname("esp32-project");
ArduinoOTA.begin();
}
void loop() {
ArduinoOTA.handle();
// ... rest of your program ...
}
Once this is running, the Arduino IDE can show the board as a network port alongside the usual USB ports, and future uploads go over Wi-Fi instead of a cable.
KEY IDEA
Add OTA support before a device is sealed up or installed somewhere hard to reach — retrofitting it after the fact means one last cable trip.