Source: https://mokxi.com/libraries/elegantota
Updated: 2026-11-22

Libraries / Network

Arduino library · Network

# ElegantOTA: firmware updates from a browser page

Yes, you can build with the ElegantOTA library online in Mokxi with nothing to install. Its hardware is not simulated, so a sketch says plainly that it cannot reach the device. The example below, "A web server with an /update page beside it", runs on the ESP32-C3-DevKitM-1.

Run the example in Mokxi See the calls

Built in on Mokxi: #include <ElegantOTA.h> and it builds, with nothing to install. Free, and no account needed.

## What ElegantOTA does

ElegantOTA, by Ayush Sharma, adds an /update page to a web server already running on an ESP32, ESP8266 or Pico W. Open it in a browser on the same network, pick the compiled .bin file, and the board flashes itself and restarts. Nothing is needed on the computer beyond a browser, which makes it handy for boards mounted where a USB cable cannot reach.

Version 3 is a single global object. You pass it your server with ElegantOTA.begin(&server), call ElegantOTA.loop() in loop() so it can finish the update and reboot, and optionally attach onStart(), onProgress() and onEnd() to log or show progress. setAuth() puts a user name and password on the page. It works with the core WebServer or with ESPAsyncWebServer, chosen at compile time.

In Mokxi the library compiles and the Demo example runs: the root page answers in the Web panel and /update answers too, but over-the-air updates are not simulated. The page says so, nothing is uploaded or flashed, and the callbacks never run. To try new code, press Run to load a new build.

Library Manager name | ElegantOTA

Author | Ayush Sharma

Include | #include <ElegantOTA.h>

Boards | ESP32-C3, ESP32-C6, Seeed XIAO ESP32-C3, ESP32-C3 SuperMini, Seeed XIAO ESP32-C6, ESP32 DevKit, ESP32-DevKitC V4, LOLIN32 Lite, Wemos D1 R32, Cheap Yellow Display, TTGO T-Display, ESP32-S3-DevKitC-1, Seeed XIAO ESP32-S3, Arduino Nano ESP32, ESP32-S3-CAM, ESP8266 NodeMCU, Raspberry Pi Pico W

In the simulator | Builds and runs, and says plainly that the hardware behind it is not simulated.

## Install it

It builds on ESP32-C3, ESP32-C6, Seeed XIAO ESP32-C3, ESP32-C3 SuperMini, Seeed XIAO ESP32-C6, ESP32 DevKit, ESP32-DevKitC V4, LOLIN32 Lite, Wemos D1 R32, Cheap Yellow Display, TTGO T-Display, ESP32-S3-DevKitC-1, Seeed XIAO ESP32-S3, Arduino Nano ESP32, ESP32-S3-CAM, ESP8266 NodeMCU, Raspberry Pi Pico W.

In Mokxi it is built in: #include <ElegantOTA.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "ElegantOTA" by Ayush Sharma from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add ElegantOTA to lib_deps in PlatformIO. Mokxi follows the calls of release 4.0.0, so a sketch written here builds there too.

What to know in the simulator: Over-the-air updates are not simulated: the /update page says so, nothing is uploaded or flashed, and the callbacks never run (press Run to load a new build). 4.0 kept 3.x’s calls; /ota/metadata answers with zero-sized partitions. The AsyncWebServer form needs ESPAsyncWebServer.h first or ELEGANTOTA_USE_ASYNC_WEBSERVER 1.

- ESP32-C3
- ESP32-C6
- Seeed XIAO ESP32-C3
- ESP32-C3 SuperMini
- Seeed XIAO ESP32-C6
- ESP32 DevKit
- ESP32-DevKitC V4
- LOLIN32 Lite
- Wemos D1 R32
- Cheap Yellow Display
- TTGO T-Display
- ESP32-S3-DevKitC-1
- Seeed XIAO ESP32-S3
- Arduino Nano ESP32
- ESP32-S3-CAM
- ESP8266 NodeMCU
- Raspberry Pi Pico W

## The calls you will use

In the order a sketch meets them.

### ElegantOTA.begin(&server)

Adds the /update page and its upload handler to your WebServer or AsyncWebServer. Call it after your own server.on() routes.

### ElegantOTA.loop()

Finishes a pending update and reboots when it is due. Call it on every pass of loop(), after server.handleClient() if you use the core server.

### ElegantOTA.onStart(otaStarted)

Registers a function run when an upload begins, a good place to switch off motors or close files.

### ElegantOTA.onProgress(otaProgress)

Registers a function given the bytes written so far and the total, for a progress line on Serial.

### ElegantOTA.onEnd(otaEnded)

Registers a function given true when the update succeeded and false when it failed.

### ElegantOTA.setAuth("admin", "secret")

Asks for a user name and password before the update page opens. Without it anyone on the network can flash the board.

### ElegantOTA.setAutoReboot(false)

Stops the automatic restart after a successful update, so your own code can decide when to reboot.

## Example: A web server with an /update page beside it

On the ESP32-C3-DevKitM-1. It runs in the browser exactly as printed.

sketch.ino · ESP32-C3-DevKitM-1

Open it in the editor, wired and ready to run

## Common errors and how to fix them

### no matching function for call to 'begin(AsyncWebServer*)'

ElegantOTA 3 builds for the core WebServer unless told otherwise. Include ESPAsyncWebServer.h before ElegantOTA.h, or set ELEGANTOTA_USE_ASYNC_WEBSERVER to 1 in the library’s header or as a build flag, then rebuild.

### The upload reaches 100% but the board never restarts

In version 3 the reboot happens inside ElegantOTA.loop(). Add it to loop() and keep loop() free of long delay() calls, or the board waits forever with the new firmware unused.

### Upload fails at once with "Not enough space"

The partition scheme has no room for a second copy of the firmware. Choose a scheme with OTA in the board menu, such as the default with two app partitions, and upload once over USB to apply it.

## Questions and answers

### ElegantOTA or ArduinoOTA?

ArduinoOTA pushes a build from the Arduino IDE or PlatformIO over the network. ElegantOTA lets anyone with a browser upload a .bin file, with no IDE. Many projects use one or the other, and some use both.

## Keep going

### Learn

- Connect a Board to WiFi and Serve a Page
- ESP32 Not Connecting to WiFi: Causes and Fixes

### More network libraries

- PubSubClient
- MQTT
- Blynk
- ThingSpeak
- WiFiManager
- WiFi, HTTPClient and WebServer (ESP32 core)
- WebSockets
- NTPClient

Every built-in library · Open the editor

## Try ElegantOTA without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
