0Pricing
Arduino & IoT Academy · Lección

Activar ArduinoOTA

Añada compatibilidad con OTA y cargue el programa por WiFi.

Activar ArduinoOTA es una lección gratuita de Arduino & IoT Academy en CoddyKit. Esta es la lección 2 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Arduino & IoT Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Arduino & IoT Academy incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

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. ✅

Preguntas frecuentes

¿La lección «Activar ArduinoOTA» es gratis?

Sí — el texto completo de «Activar ArduinoOTA» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Arduino & IoT Academy, actualiza a CoddyKit PRO. El curso de Arduino & IoT Academy incluye 4 lecciones en total.

¿Qué aprenderé en «Activar ArduinoOTA»?

Añada compatibilidad con OTA y cargue el programa por WiFi. Practicas Arduino & IoT Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Arduino & IoT Academy?

No se requiere experiencia previa. Arduino & IoT Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 2 de 4.

¿Cuánto tiempo toma la lección «Activar ArduinoOTA»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Arduino & IoT Academy?

Sí. Cada lección de Arduino & IoT Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Por qué OTA es importante en campo
  2. Activar ArduinoOTA
  3. Alojar una página web de actualización
  4. Revertir una actualización defectuosa
← Volver a Arduino & IoT Academy