This project shows you how to update the code on your ESP32 or ESP8266 microcontroller without plugging in a USB cable. Normally, every time you want to change your program, you need to physically connect the board to your laptop. With this method, you upload a special sketch to the board once via USB, and after that, all future code updates happen wirelessly over WiFi. Just open your phone's browser, go to the board's IP address, pick your new code file, and hit upload. That's it. Super useful when your board is mounted somewhere hard to reach.
DetailsTo update firmware on any microcontroller over the air, the board needs a way to receive new code wirelessly and write it to flash memory. The ESP32 and ESP8266 already have built-in WiFi, which makes them perfect candidates. The Web Updater OTA method works by running a tiny web server on the board itself. You open the board's IP address in your smartphone browser, upload a compiled.bin file, and the board flashes itself and reboots. No USB cable needed after the first setup.
The ESP32 manages OTA using a dual-partition system in its flash memory — ota_0 and ota_1. New firmware is written to the inactive partition while the board keeps running. Once the write is verified, the board switches over and reboots into the new code. This is what makes OTA safe. If the update fails, the board rolls back to the previous working firmware automatically.
The board's factory image has no OTA capability, so the first upload must be done via USB from the Arduino IDE. Arduino IDE already includes a ready-to-use example. Navigate to File > Examples > ArduinoOTA > OTAWebUpdater, enter your WiFi credentials, and upload.
After uploading, open Serial Monitor at 115200 baud and press the EN/Reset button. The board will print its assigned IP address, for example 192.168.1.47. Note it down, or better yet, assign it a static IP from your router's DHCP settings so it never changes. This is the address you will type into your phone's browser every time you want to push an update.
Step 3 — Export new sketches as.bin filesFor every future update, write your sketch on the PC as normal, then go to Sketch > Export Compiled Binary. This saves a.bin file in your sketch folder. Transfer it to your phone via Google Drive, WhatsApp, AirDrop, or email, whatever is convenient. Make sure the file lands somewhere your phone's browser file picker can access it.
Step 4 — Flash from your smartphone browserOpen Chrome or Safari on your phone and go to http://192.168.1.47 You will see the OTA login and upload page served by the board. Log in with the credentials set in your sketch, select your.bin file, and tap Upload. The process takes 10 to 30 seconds. The board reboots automatically and runs the new firmware.
For a much cleaner upload interface with a progress bar, consider using the ElegantOTA library instead of the default OTAWebUpdater example. It requires only three extra lines of code added to any existing sketch and produces a polished browser UI.
The only rule to remember: every sketch you upload from now on must include the OTA routine. If you upload a sketch without it, the web server disappears and you will have to go back to USB for the next update. Download all sketch files and Gerber PCB files from the links above. PCBs can be ordered from JLCPCB starting at just $2 for 5 boards, check them out here: https://jlcpcb.com









Comments