ESP8266_Demo.ino 823 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <ESP8266WiFi.h>
  2. #include <WiFiClient.h>
  3. #include <ESP8266WebServer.h>
  4. #include <ElegantOTA.h>
  5. const char* ssid = "........";
  6. const char* password = "........";
  7. ESP8266WebServer 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("/", []() {
  24. server.send(200, "text/plain", "Hi! I am ESP8266.");
  25. });
  26. ElegantOTA.begin(&server); // Start ElegantOTA
  27. server.begin();
  28. Serial.println("HTTP server started");
  29. }
  30. void loop(void) {
  31. server.handleClient();
  32. }