Devices & Components
Arduino Uno Rev3
NodeMCU ESP8266
Software & Tools
Arduino IDE
Project description
Code
Arduino Sketch for the Project
c
1#include <WiFi.h> 2#include <ESPAsyncWebServer.h> 3 4const char* ssid = "ELDRADO"; // CHANGE IT 5const char* password = "amazon123"; // CHANGE IT 6 7AsyncWebServer server(80); 8 9void setup() { 10 Serial.begin(9600); 11 12 // Connect to Wi-Fi 13 WiFi.begin(ssid, password); 14 while (WiFi.status() != WL_CONNECTED) { 15 delay(1000); 16 Serial.println("Connecting to WiFi..."); 17 } 18 Serial.println("Connected to WiFi"); 19 20 // Print the ESP32's IP address 21 Serial.print("ESP32 Web Server's IP address: "); 22 Serial.println(WiFi.localIP()); 23 24 // Define a route to serve the HTML page 25 server.on("/", HTTP_GET, [](AsyncWebServerRequest* request) { 26 Serial.println("ESP32 Web Server: New request received:"); // for debugging 27 Serial.println("GET /"); // for debugging 28 request->send(200, "text/html", "<html><body><h1>Hello, ESP32!</h1></body></html>"); 29 }); 30 31 // Start the server 32 server.begin(); 33} 34 35void loop() {}
Comments
Only logged in users can leave comments