0Pricing
Arduino & IoT Academy · Lekcja

Udostępnianie strony aktualizacji

Przesyłać firmware z formularza w przeglądarce.

Udostępnianie strony aktualizacji to bezpłatna lekcja Arduino & IoT Academy na CoddyKit. To lekcja 3 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.

Update From a Browser

Sometimes you want to flash a device without the Arduino IDE at all. A web update page lets anyone upload firmware from a browser.

The Board Becomes a Server

Your ESP32 runs a tiny web server that serves an upload form, so a phone or laptop can send it a new binary.

Bring In the Libraries

You combine a web server with the Update library, which knows how to write incoming bytes into flash memory.

#include <WebServer.h>
#include <Update.h>
WebServer server(80);

Serve an Upload Form

The root page returns a simple HTML form with a file picker and a submit button for the firmware file.

server.on("/", []() {
  server.send(200, "text/html",
    "<form method='POST' action='/update' enctype='multipart/form-data'><input type='file' name='fw'><input type='submit'></form>");
});

Where Did .bin Come From?

In the IDE, Sketch then Export Compiled Binary creates the .bin file you will pick in that upload form.

Open the Update Stream

When the upload starts, you tell the chip how big the image is so Update.begin() can reserve flash space for it.

Update.begin(UPDATE_SIZE_UNKNOWN);

Write the Incoming Chunks

Firmware arrives in pieces. You feed each chunk to Update.write() as it lands, building the new image in flash.

Update.write(upload.buf, upload.currentSize);

Finish and Verify

When the last byte arrives, Update.end(true) checks the image is complete and valid before marking it ready to boot.

if (Update.end(true)) Serial.println("Update OK");

Reboot Into New Code

A successful update needs a fresh start. Call ESP.restart() so the board boots into the firmware you just uploaded. 🔄

ESP.restart();

Guard the Page

Anyone who reaches this page can reflash your device, so add a login or token check before accepting any upload.

Keep the Server Alive

Just like OTA, the web server needs attention. Call server.handleClient() in loop so it can accept the upload request.

void loop() { server.handleClient(); }

Quick Check

Think about which library actually writes firmware to flash.

Recap

Run a web server that serves an upload form, feed the .bin to the Update library, verify it, then restart, all guarded behind a login. 🌐

Często zadawane pytania

Czy lekcja „Udostępnianie strony aktualizacji” jest bezpłatna?

Tak — pełny tekst „Udostępnianie strony aktualizacji” 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 „Udostępnianie strony aktualizacji”?

Przesyłać firmware z formularza w przeglądarce. Ć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 3 z 4.

Ile czasu zajmuje lekcja „Udostępnianie strony aktualizacji”?

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

  1. Dlaczego OTA ma znaczenie w terenie
  2. Włączanie ArduinoOTA
  3. Udostępnianie strony aktualizacji
  4. Wycofywanie nieudanej aktualizacji
← Powrót do Arduino & IoT Academy