Abilitare ArduinoOTA
Aggiunga il supporto OTA e carichi tramite WiFi.
Abilitare ArduinoOTA è una lezione Arduino & IoT Academy gratuita su CoddyKit. Questa è la lezione 2 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Arduino & IoT Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Arduino & IoT Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
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. ✅
Domande Frequenti
La lezione «Abilitare ArduinoOTA» è gratuita?
Sì — il testo completo di «Abilitare ArduinoOTA» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Arduino & IoT Academy, passa a CoddyKit PRO. Il corso Arduino & IoT Academy include 4 lezioni in totale.
Cosa imparerò in «Abilitare ArduinoOTA»?
Aggiunga il supporto OTA e carichi tramite WiFi. Eserciti Arduino & IoT Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Arduino & IoT Academy?
Non è richiesta alcuna esperienza precedente. Arduino & IoT Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 2 di 4.
Quanto tempo richiede la lezione «Abilitare ArduinoOTA»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Arduino & IoT Academy?
Sì. Ogni lezione Arduino & IoT Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Perché OTA è importante sul campo
- Abilitare ArduinoOTA
- Ospitare una pagina web di aggiornamento
- Ripristinare un aggiornamento errato