ClavdaClavda

Update ESP32 firmware over the air with the Arduino IDE

Export an Arduino sketch as a .bin, upload it in Clavda, and the ESP32 installs it from anywhere, without a USB cable. In C++ or C.

Updated 2 min read

Arduino's built-in OTA only works on the same local network as the board. With the ClavdaOTA library in your sketch, the board downloads updates through Clavda instead, so you can update it from anywhere it has Wi-Fi, behind any router.

What you need

  • An ESP32 already connected to Clavda with the Arduino IDE and showing green under Devices.
  • The partition scheme from setup, Tools → Partition Scheme → Minimal SPIFFS (1.9MB APP with OTA), flashed once over USB. Without two app slots there is no room to install an update.

Install an update

Give the build a new version

Change CLAVDA_FIRMWARE_VERSION for every build you upload, from "1.0.0" to "1.0.1", say. It is at the top of the .ino in C++, and of app.c in C:

#define CLAVDA_FIRMWARE_VERSION "1.0.1"

Clavda counts an update as done only when the board reconnects reporting the new version, so a build with an unchanged version never shows as installed.

Export the binary

Choose Sketch → Export Compiled Binary. The file to upload is <sketch>.ino.bin, in the sketch's build/<board> folder: not the .merged.bin, the .bootloader.bin or the .partitions.bin. Keep the same partition scheme as the board was flashed with.

Upload it in Clavda

Open the device's Connect sheet, upload the .bin, and press Update now.

Let the board install it

The board downloads the new firmware, checks it, and restarts into it. Once it reconnects reporting the new version, the update shows as done.

Version strings

Start with a letter or digit and use up to 31 letters, digits, dots, underscores, plus signs or hyphens: 1.0.1, 2026.10.15 and v2-beta all work.

Follow an update from your code

The library can tell your sketch when an update arrives, how far the download is, and how it ended. Return false from the request callback to put an update off, while a motor is running, say: the console then shows the job as deferred rather than failed.

Add these to setup(), before ClavdaOTA.begin():

MySketch.ino
ClavdaOTA.onUpdateRequest([](const ClavdaUpdateRequest &request) {
  Serial.printf("Update %s offered, %u bytes\n", request.version, (unsigned)request.size);
  return true;  // false puts it off
});
ClavdaOTA.onStart([]() { Serial.println("Update started"); });
ClavdaOTA.onProgress([](size_t current, size_t total) {
  Serial.printf("%u of %u bytes\n", (unsigned)current, (unsigned)total);
});
ClavdaOTA.onEnd([](bool success) {
  Serial.println(success ? "Update written, restarting" : "Update failed");
});

Keep updates reliable

  • Call the library's loop on every pass through loop(), ClavdaOTA.loop() in C++ or clavda_loop() in C, and avoid long delay() calls. Updates install from there.
  • Keep your firmware small enough for one app slot: with the Minimal SPIFFS scheme, each slot is 1.9 MB. The IDE prints the sketch size after each build.

Next steps