Este es uno de los primeros programas para mostrar un mensaje desde cualquier navegador web. Consiste en la prueba de conexión del módulo ESP32 a internet, donde el dispositivo este enlazado a la red. Como prueba de ello, se ingresará a la dirección Ip y se observará el mensaje
/*
Creado: Luis Alvarez (edualv1723@gmail.com)
https://alvelectronics.com
*/
// ESP32 Web Server: Hello World!
#include <WiFi.h>
#include <ESPAsyncWebServer.h>
// Replace with your network credentials
const char* ssid = "YourWiFiSSID";
const char* password = "YourWiFiPass";
// Create a web server object on port 80
AsyncWebServer server(80);
// HTML webpage with inline CSS styling for icons and layout
const char index_html[] PROGMEM = R"rawliteral(
Hello,world!
)rawliteral";
void setup() {
Serial.begin(9600);
// Connect to Wi-Fi
Serial.println("Connecting to Wi-Fi...");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("\nWi-Fi connected!");
Serial.println("IP Address: ");
Serial.println(WiFi.localIP());
// Define the root URL handler
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(200, "text/html", index_html);
});
// Start the server
server.begin();
Serial.println("Web server started.");
}
void loop() {
}