Any concerns? support@freenove.com
}
}
client.stop(); // stop the client connecting.
Serial.println("Client Disconnected.");
}
}
Apply for method class of WiFiServer.
WiFiServer server(port); //Apply for a Server object whose port number is 80
Connect specified WiFi until it is successful. If the name and password of WiFi are correct but it still fails to
connect, please push the reset key.
13
14
15
16
17
18
19
20
21
WiFi.disconnect();
WiFi.begin(ssid_Router, password_Router);
delay(1000);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected.");
Print out the IP address and port number of ESP32-S3.
Serial.print("IP address: ");
Serial.println(WiFi.localIP()); //print out IP address of ESP32-S3
Serial.printf("IP port: %d\n",port); //Print out ESP32-S3's port number
Turn on server mode of ESP32-S3, start automatic connection and turn on automatic reconnection.
server.begin(); //Turn ON ESP32-S3 as Server mode
WiFi.setAutoConnect(true);
WiFi.setAutoReconnect(true);
When ESP32-S3 receive messages from servers, it will print them out via serial port; Users can also send
messages to servers from serial port.
if (client.available()) { // if there's bytes to read from the
client
Serial.println(client.readStringUntil('\n')); // print it out the serial monitor
while(client.read()>0); // clear the wifi receive area cache
}
if(Serial.available()){ // if there's bytes to read from the
serial monitor
client.print(Serial.readStringUntil('\n')); // print it out the client.
while(Serial.read()>0); // clear the wifi receive area cache
}