Messaging between four slaves and one master Arduino

Hello to everyone on this forum. This is my first post and I'm gonna ask you for help with my new project. I have 5 Arduinos UNO (one is a MASTER, the rest four are SLAVEs).

There are one RC522 RFID reader connected to each other of the slaves. Each slave has to read the UID number, decode it and send proper message to the master. Message will look like "C1S1". It will be a String.

Solution has to be very stable. Messages will be send once/twice a day so I think that there won't be colissions [u]but first I have to send any message[/u] between three Arduinos. I tried with UART but It works only with one slave. When I connect next slave messages don't come to the master. I suppose that It doesn't work because you just can't connect two wires to one RX pin in master Arduino.

What is the best way to send messages like "C1S1" from one Arduino to each other? Please give me advice how to start with this project.

I have 5 Arduinos UNO (one is a MASTER, the rest four are SLAVEs).

Those terms ONLY make sense if you are using SPI to communicate between the devices.

For the purpose of discussing your question, think in terms of teacher and 4 students who KNOW better than to shout out an answer. The teacher calls on each student in turn until one knows the answer. Then a new question is asked, and the students again called on in order, until the correct answer is received.

It doesn't make sense to ask "Joe, what is the capital of Alabama", when it is Bob's turn in the hot seat. The question asked by the master/teacher needs to be appropriate for the slave that the question is directed to.

So, the SPI pins need to be used to connect the devices. Each device has a unique address. The master sets the slave select pin to choose the slave to talk to, and then asks for information. The slave, thinking it is the only slave in the universe, provides a response.

If timing is not important, you might send a clock pulse out to everyone, then have #1 count to 10, then report back. have #2, count to 1,000 and report it's findings. have #3, count to 2,000 and so on.

not a good solution, but a possible work-around

How far are the slaves from the master?

PaulS: Those terms ONLY make sense if you are using SPI to communicate between the devices.

I don't agree. They certainly have a specific meaning in the SPI context but it seems to me a very practical way to describe any sort of communication system where one device is in charge.

I agree with most of the rest of @PaulS's post.

I have a master-slave system that operates over 2.4GHz wireless to control model trains and receive data back from each train. The master sends a message with a slave's ID number. All the slaves hear the message but only the slave with the matching ID responds.

...R

I have always liked a loop system like the old HPIL. Only two connections to each node - including the master.

The master periodically sends out an "Are there any messages" command and the slaves will each respond with any messages as they get the message. If the initial command does not get back to the master you know there is something wrong somewhere.

I tried with UART but It works only with one slave. When I connect next slave messages don't come to the master. I suppose that It doesn't work because you just can't connect two wires to one RX pin in master Arduino.

You can connect the slave tx pins to the master rx pin, but you need to provide some electrical isolation on the tx pins so they don't hold the master rx pin high. Add small signal diodes between the master rx and the individual tx pins, with the diode band end connected to the slave tx pin. This will prevent the slave tx pins back feeding the master rx pin keeping it high when an individual slave tx pin tries to pull the master rx pin low.

groundfungus: How far are the slaves from the master?

Circa 10-15m without any wall between each other.

PaulS: For the purpose of discussing your question, think in terms of teacher and 4 students who KNOW better than to shout out an answer. The teacher calls on each student in turn until one knows the answer. Then a new question is asked, and the students again called on in order, until the correct answer is received.

That makes sense. I've thought about that kind of solution too but you finally confirmed my opinion. Thanks a lot. Comunication should begin in the master - not slave.

Robin2: I have a master-slave system that operates over 2.4GHz wireless to control model trains and receive data back from each train. The master sends a message with a slave's ID number. All the slaves hear the message but only the slave with the matching ID responds.

...R

It could be a good solution. Did you do your communication with NRF 24L01?

duff121: Did you do your communication with NRF 24L01?

No. The deltino devices I used (because they are very small) use Cypress transceivers - but I'm sure there is little to choose between the two brands.

...R