/* * Sample extracted from https://techtutorialsx.com/2017/11/13/esp32-arduino-setting-a-socket-server/ * and modified by Cuautli Garcia * * FabAcademy * * Version 1.0 * Last autor: Cuautli Garcia - cuautli.garciaa@gmail.com * */ //Required libraries #include // Wifi credentials const char* ssid = "HOME_2.4G"; const char* password = "5GaRcIaS"; //Set the web server port number to 80 WiFiServer wifiServer(80); //String to store the received information from the computer String cadenarecibida; void setup() { Serial.begin(115200);//Initialize the serial protocol delay(1000); //Wait a second WiFi.begin(ssid, password);//Start the WiFi protocol //While the wifi is not connected while (WiFi.status() != WL_CONNECTED) { delay(1000); //Wait a second //Display the following text Serial.println("Connecting to WiFi.."); } //When the Wifi is connected Serial.println("Connected to the WiFi network"); Serial.println(WiFi.localIP());//Prin the IP addres wifiServer.begin();//Start the Wifi server } void loop() { //Start a Wifi client WiFiClient client = wifiServer.available(); if (client) {//If a client is detected while (client.connected()) {//While the client is connected while (client.available()>0) {//While the bus is available char c = client.read(); //Read the information from the interface client.write(c); //Write back whatever is sent if (c != ' ') //If there is not a space cadenarecibida += c; //Save the information } Serial.println(cadenarecibida);//Print the whole string delay(10); //Wait 10 ms cadenarecibida=""; //Clean the string } client.stop(); //Stop the client Serial.println("Client disconnected"); } }