I am trying to communicate between two ESP modules and I would like to check if what I am doing makes sense.
I have one ESP module running a simple WiFiWebServer.
My DHCP server assigns to it the (fixed) address 192.168.1.5 and it works correctly by serving the two following requests:
http://192.168.1.5/on --> LED is turned on
http://192.168.1.5/off --> LED is turned off
On another ESP module, I run a WiFiClient that tries to send the above commands with HTTP GET.
At the moment, the client ESP cannot connect to the server ESP.
The code below results in "connection failed":
const char* host ="192.168.1.5";
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
But on a web page, I can see the welcome page of the server at the address:
http://192.168.1.5:80
Could you please tell me if you know what I am doing wrong?
Thanks!
Marcello