This is an old revision of the document!
#include <Arduino.h> #include <WiFi.h> #include <AsyncTCP.h> #include <ESPAsyncWebServer.h> #include <ElegantOTA.h> const char* ssid = "TP-Link_2A64"; const char* password = "99481100"; // OTA basic auth (recommended) const char* ota_user = "admin"; const char* ota_pass = "change-me"; AsyncWebServer server(80); void setup() { Serial.begin(115200); delay(200); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); Serial.print("Connecting to WiFi"); while (WiFi.status() != WL_CONNECTED) { delay(300); Serial.print("."); } Serial.println(); Serial.print("Connected. IP: "); Serial.println(WiFi.localIP()); // Simple landing page server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) { request->send(200, "text/plain", "ESP32-C6 Sparrow OTA ready.\n" "Go to /update to upload new firmware."); }); // Start ElegantOTA (async mode with ESPAsyncWebServer) ElegantOTA.begin(&server, ota_user, ota_pass); server.begin(); Serial.println("HTTP server started."); Serial.println("Open http://<device-ip>/update"); } void loop() { ElegantOTA.loop(); }