Chat freely about anything...

User avatar
By lampshade
#23697 Hey,

i just wanted to connect 3 ESP8266 (connected with temperature sensors) via TCP and send and receive the data from each of them. So every ESP should send and receive the temperature of every module.

Is it possible to run every of them as a TCP client and server and send the data step by step?

i use nodemcu for this. But first of all i wanted to know, if this is the right way to start this, or if there are simpler alternatives.
or ist it possible to receive data as a client? i read some posts, that the esp had to be a server to receive data.

thank you and regards
lampshade
User avatar
By kolban
#23710 You might want to consider using UDP as opposed to TCP. UDP allows you to broadcast ... so if you have more than 3 devices or some are down, they can all hear from each other. It would also allow you to have devices transmit to others without having to know the partner IP addresses.
User avatar
By lampshade
#23808 seems to be a great idea, but honestly i dont know how i can put this in a Lua code. So maybe someone could help me, or point me to the right direction.
a more precise explanaition of my problem:

i have
ESP1
ESP2
ESP3
every of them is connected to a sensor. i want ESP1 and ESP2 to send data to ESP3 and ESP3 should calculate the average of the data.

Now ESP2 and ESP3 should send theire data to ESP1 and ESP1 should calculate the average

Than ESP1 and ESP3 should send data to ESP2

your multicast idea is great so ESP1 sends data automaticly to ESP2 and ESP3 but i dont understand how i can realize this codewise(Lua) and how i can store the received data to a variable
User avatar
By rlettow
#24627 Have you considered using MQTT publish/subscribe? Nodemcu has builtin support for MQTT and is very easy to implement within lua code. The only downside is the requirement of running a MQTT Broker on a computer within the network.