#include const char* ssid = "XiaoEsp32Network"; const char* password = "password"; const char* host = "192.168.4.1"; // The IP address of the first Xiao WiFiClient client; void setup() { Serial.begin(115200); delay(10); // Connect to the access point created by the first Xiao Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("Connected to AP"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); // Connect to the server while (!client.connect(host, 80)) { Serial.println("Connection to host failed, retrying..."); delay(1000); } Serial.println("Connected to server"); } void loop() { if (client.connected()) { if (client.available()) { String message = client.readStringUntil('\n'); Serial.print("Received message from server: "); Serial.println(message); } if (Serial.available()) { String message = Serial.readStringUntil('\n'); client.print(message); } } else { Serial.println("Disconnected from server, retrying..."); while (!client.connect(host, 80)) { Serial.println("Connection to host failed, retrying..."); delay(1000); } Serial.println("Connected to server"); } delay(100); }