// ESP32 WiFi access point and Web Server
#include <WiFi.h>
#include <ESPAsyncWebServer.h>
const char* ssid = "UAV_1234";
const char* password = "12345678";
AsyncWebServer server(80);
void setup() {
Serial.begin(115200);
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
Serial.println(WiFi.localIP());
// Route handler for root URL ("/")
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(200, "text/html", "<html><body><h1>ESP32 Server</h1></body></html>");
});
// Route handler for "/data" URL
server.on("/data", HTTP_GET, [](AsyncWebServerRequest *request){
String data = "Sensor data: 123"; // Replace with your actual data
// Send the data as the response
request->send(200, "text/plain", data);
});
// Start server
server.begin();
}
void loop() {
// Nothing to do here
}