ESP8266_Async_Demo.ino 850 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <ESP8266WiFi.h>
  2. #include <ESPAsyncTCP.h>
  3. #include <ESPAsyncWebServer.h>
  4. #include <AsyncElegantOTA.h>
  5. const char* ssid = "........";
  6. const char* password = "........";
  7. AsyncWebServer server(80);
  8. void setup(void) {
  9. Serial.begin(115200);
  10. WiFi.mode(WIFI_STA);
  11. WiFi.begin(ssid, password);
  12. Serial.println("");
  13. // Wait for connection
  14. while (WiFi.status() != WL_CONNECTED) {
  15. delay(500);
  16. Serial.print(".");
  17. }
  18. Serial.println("");
  19. Serial.print("Connected to ");
  20. Serial.println(ssid);
  21. Serial.print("IP address: ");
  22. Serial.println(WiFi.localIP());
  23. server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
  24. request->send(200, "text/plain", "Hi! I am ESP8266.");
  25. });
  26. AsyncElegantOTA.begin(&server); // Start ElegantOTA
  27. server.begin();
  28. Serial.println("HTTP server started");
  29. }
  30. void loop(void) {
  31. }