f the assigned password is shorter than 8 characters, the SSID will be ignored. If you want to change the SSID, make sure the password is longer than 8 characters or that there is no password.
client
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
// http://www.robotronix.co.il #include <WiFi.h> const uint16_t port = 80; const char * host = "192.168.4.1"; void setup() { char ssid[40]; char password[40]; strcpy(ssid,"xxxxxx1"); strcpy(password,"mpcar2020"); Serial.begin(115200); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.println("..."); } Serial.print("WiFi connected with IP: "); Serial.println(WiFi.localIP()); } void loop() { WiFiClient client; if (!client.connect(host, port)) { Serial.println("Connection to host failed"); delay(1000); return; } Serial.println("Connected to server successful!"); client.print("Hello from ESP32!\n"); Serial.println("Disconnecting..."); client.stop(); delay(10000); } /* void loop() { WiFiClient client = wifiServer.available(); if (client) { while (client.connected()) { while (client.available()>0) { char c = client.read(); Serial.write(c); } delay(10); } client.stop(); Serial.println("Client disconnected"); } } */ |
server
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
// http://www.robotronix.co.il #include <WiFi.h> WiFiServer server(80); void setup() { char ssid[40]; char password[40]; strcpy(ssid,"xxxxxx1"); strcpy(password,"mpcar2020"); // password mast br higher then 8 Serial.begin(115200); Serial.print("Setting soft access point mode"); Serial.begin(115200); WiFi.softAP(ssid, password); Serial.print("AP IP address: "); Serial.println(WiFi.softAPIP()); Serial.print("WiFi MAC address: "); Serial.println(WiFi.macAddress()); server.begin(); } void loop() { WiFiClient client = server.available(); if (client) { while (client.connected()) { while (client.available()>0) { char c = client.read(); Serial.write(c); //Serial.print(c); } delay(10); } client.stop(); Serial.println("Client disconnected"); } } |