0Pricing
Arduino & IoT Academy · Lesson

Enable ArduinoOTA

Add OTA support and upload over WiFi.

Enable ArduinoOTA is a free Arduino & IoT Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Arduino & IoT Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Meet ArduinoOTA

The simplest way to update over WiFi is the ArduinoOTA library. It makes your board appear as a network port inside the Arduino IDE.

Include the Library

OTA rides on WiFi, so you pull in both headers at the top of your sketch before anything else runs.

#include <WiFi.h>
#include <ArduinoOTA.h>

Connect First

OTA can only work once you are online. In setup you join WiFi with your network name and password before starting OTA.

WiFi.begin("MyNetwork", "secret123");
while (WiFi.status() != WL_CONNECTED) { delay(500); }

Start the Service

One call wakes the updater. ArduinoOTA.begin() registers your board on the network so the IDE can find it.

ArduinoOTA.begin();

Give It a Name

Set a clear hostname so your device is easy to spot in the IDE's port list, especially when several boards share one network.

ArduinoOTA.setHostname("living-room-sensor");

Protect It With a Password

Always set an OTA password so a stranger on your WiFi cannot push their own code to your hardware.

ArduinoOTA.setPassword("flashMe!");

Handle OTA in the Loop

The updater is not automatic. You must call ArduinoOTA.handle() on every pass of loop so it can listen for an incoming upload.

void loop() {
  ArduinoOTA.handle();
}

Never Block the Loop

A long delay starves handle() and the upload fails. Keep loop quick so OTA always gets a chance to respond.

Watch the Progress

You can attach callbacks like onProgress to print how much of the new firmware has arrived during an upload.

ArduinoOTA.onProgress([](unsigned int p, unsigned int t) {
  Serial.printf("%u%%\n", (p * 100) / t);
});

Find the Network Port

After uploading once by USB, open the IDE's port menu. Your named board appears under network ports, ready for wireless flashing. 📶

Upload Wirelessly

Pick the network port, hit upload, and enter your password. From now on, new code flows entirely over the air.

Quick Check

One method must run constantly for OTA to work.

Recap

Include ArduinoOTA, connect to WiFi, call begin() with a hostname and password, then run handle() every loop to flash your board wirelessly. ✅

Frequently asked questions

Is the “Enable ArduinoOTA” lesson free?

Yes — the full text of “Enable ArduinoOTA” is free to read here on the web, and the Arduino & IoT Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Arduino & IoT Academy course, upgrade to CoddyKit PRO.

What will I learn in “Enable ArduinoOTA”?

Add OTA support and upload over WiFi. You practise Arduino & IoT Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Arduino & IoT Academy?

No prior experience is required. Arduino & IoT Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Enable ArduinoOTA” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Arduino & IoT Academy lesson?

Yes. Every Arduino & IoT Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Why OTA Matters in the Field
  2. Enable ArduinoOTA
  3. Host a Web Update Page
  4. Roll Back a Bad Update
← Back to Arduino & IoT Academy