Hello !
I want to make a WIFI network with up to ten ESP32 OR ESP8266 microcontrollers.
Assigned IP Addresses : 192.168.1.10-192.168.1.10 .
Please tell me how can I send a text message from
one ESP module to another one based on IP addresses ?
My command should look like this :
SEND "text message" TO 192.168.1.5
I don't want to use the UDP protocol to broadcast the
message to all the network because of the data loss...
Can you help me, please ?
Thank You !
Define a listening (server) port on a known port number on each machine.
From the sending machine, open a TCP connection to the known port at the target address.
Once the connection is established, send data and close the connection.
The target machine will receive data from the connection and then see that the connection has been closed.
Can you provide me a small sample to do that, please ?
Thank You !
tomcat2900:
Can you provide me a small sample to do that, please ?
Thank You !
File->Examples->ESP8266WiFi->WiFiClientBasic
File->Examples->ESP8266WiFi->WiFiManualWebServer (It's only a "Web" server because it uses Port 80, pick your own port number)
In your loop() use the code from the server example to accept connections. When you want send a message, use the client example to make a connection and send data.
I will try to do that.
Can I use the same method to develop a software in Visual Basic and to send
messages from the PC to ESPs and from ESPs to the PC over WIFI Network and knowing the IP address of the PC ?
Thank You Very Much !
"File->Examples->ESP8266WiFi->WiFiManualWebServer (It's only a "Web" server because it uses Port 80, pick your own port number)"
Just trying the "WiFiManualWebServer" example and the code is somewhat flawed into being to select another port to operate on besides port 80. The problem in serving the web page is that uses the assigned IP address without appending the different port if a different port used. The url in the served web page does not account for the different port in use and clicking the selection in the page will fail.
zoomkat:
The url in the served web page does not account for the different port in use and clicking the selection in the page will fail.
Yes. Those should be changed to relative URLs.
// Send the response to the client
// it is OK for multiple small client.print/write,
// because nagle algorithm will group them into one single packet
client.print(F("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\nGPIO is now "));
client.print((val) ? F("high") : F("low"));
client.print(F("
Click <a href='/gpio/1'>here</a> to switch LED GPIO on,"));
client.print(F("or <a href='/gpio/0'>here</a> to switch LED GPIO off.</html>"));
I moved the server to 8080 (WiFiServer server(8080)
and ran the sketch on a "WeMos D1 R1" clone. The relative URLs work as expected.
The 8266 can only have, IIRC, FOUR simultaneous connections....
Regards,
Ray L.
"I moved the server to 8080 (WiFiServer server(8080)
and ran the sketch on a "WeMos D1 R1" clone. The relative URLs work as expected."
Making the url relative makes it easier to run a number of 8266 boards on different ports on a lan and to be accessed from the outside world via virtual servers/ports being set in the main router.
Hi John,
Thanks for the examples, when I finally get around to it they are going to be useful to me.
++Karma; //Thank you.