#include // For ESP32, use #include const char *ssid = "ESP_AP"; // Set your AP SSID const char *password = "12345678"; // Set your AP password WiFiServer server(80); // TCP server on port 80 void setup() { Serial.begin(115200); WiFi.softAP(ssid, password); // Start the AP Serial.println(); Serial.print("AP IP address: "); Serial.println(WiFi.softAPIP()); server.begin(); // Start TCP server } void loop() { WiFiClient client = server.available(); // Listen for incoming clients if (client) { // If a new client connects, Serial.println("New Client."); String currentLine = ""; while (client.connected()) { // loop while the client's connected if (client.available()) { // if there's bytes to read from the client, char c = client.read(); // read a byte Serial.write(c); // print it to the Serial Monitor currentLine += c; if (c == '\n') { // if the byte is a newline character if (currentLine.length() == 1) { // if the current line is empty, client.println("Hello from ESP AP!"); // send a reply to the client break; } else { // if you got a newline, then clear currentLine currentLine = ""; } } } } client.stop(); // Close the connection Serial.println("Client Disconnected."); } }