Ways of communication between two Arduinos? I have two circuits one having a ultra sound sensor and one other having a relay module. So i'm trying to establish communication between the two to send and recieve data. I just want to know which way is the best so that one arduino will send data only when the other is powered and able to recieve data. So that there is no problem when one circuit is powered on and the other is not and the data is not sent until the connection between the two is established .This is because the circuits are powered by different power sources and the current is not predictable and i dont want any miscommunication happening between them.
any way is okay like rf or wifi or some other methods? Using other devices is also an option like ESP32 which has builtin wifi and bluetooth, But wired is not possible because the distance is too big like about 15-17 meters and using the same power source is not viable for the same reason. Tell me also if the distance im worried about is not a problem?
Let the ultrasound-module broadcast measurements and not care about whether anyone are listening or not. If you are using wifi, you can send to the broadcast address of the network you are using. Then the ultrasound-module does not need to know anything about the receiver, like ip address or number of receivers. The only thing you need to make sure is that they are on the same subnet. If you want to, you can later put another module on the same subnet and it will also receive the data.
If you establish a handshake protocol it complicates things, because there are so many cases you need to consider. What should happen if communication link dies after handshake, but before data are transmittet? Should the receiver acknowledge the data? What should the sender do, if it does not receive the acknowledge? etc...
If the only thing the sender is using the handshake for is to know whether to send data or not, then just send it and forget about it. If it was to do something special, in case there are no receiver, like logging data and send the log when the receiver comes back online, then there is a use case for the handshaking.