Włączanie ArduinoOTA
Dodać obsługę OTA i przesyłać program przez Wi‑Fi.
Włączanie ArduinoOTA to bezpłatna lekcja Arduino & IoT Academy na CoddyKit. To lekcja 2 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Arduino & IoT Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Arduino & IoT Academy zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
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. ✅
Często zadawane pytania
Czy lekcja „Włączanie ArduinoOTA” jest bezpłatna?
Tak — pełny tekst „Włączanie ArduinoOTA” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Arduino & IoT Academy, przejdź na CoddyKit PRO. Kurs Arduino & IoT Academy zawiera 4 lekcji w sumie.
Co nauczysz się w „Włączanie ArduinoOTA”?
Dodać obsługę OTA i przesyłać program przez Wi‑Fi. Ćwiczysz Arduino & IoT Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć Arduino & IoT Academy?
Nie wymagamy żadnego doświadczenia. Arduino & IoT Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 2 z 4.
Ile czasu zajmuje lekcja „Włączanie ArduinoOTA”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji Arduino & IoT Academy?
Tak. Każda lekcja Arduino & IoT Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Dlaczego OTA ma znaczenie w terenie
- Włączanie ArduinoOTA
- Udostępnianie strony aktualizacji
- Wycofywanie nieudanej aktualizacji