Back to back communication between one Arduino UNO and multiple ATmega328p

Hey everyone!

I am making a project where I will have one Arduino UNO and multiple (over 200) ATmega328p (With Arduino bootloader). Basically, this is the rules I need my communication to have: - All the ATmega328p have to send data to the Arduino UNO. - ATmega328p don't communicate with each other, only with the Arduino UNO. - Arduino UNO needs to receive data from the ATmega328p. - Arduino UNO needs to send data to an individual ATmega328p. - ATmega328p needs to receive data from Arduino UNO.

Having said that, I can't figured out what is the best communication protocol to use. I have tried EasyTransfer, which kind of work, but I am having some sync issues. Sometimes, the ATmega328p send the data to the Arduino UNO, and the UNO doesn't pick up the data. Do you guys have any idea on a better and more reliable communication protocol to use?

Thank you!!

how far away from each other are the ATMEGA328 chips?

How are they all connected? RS485? The master can send a message with an "address" of the slave the message is for. The message can be one way "Hey #74, do this" and wait for the slave to reply "#74, all done" and then talk to the next one. "Hey #75, got new data to send?", "#75, no", or "#75, 10 bytes, 0x00, 0x01,...0x09," If you let the slaves send randomly, there will be times where messages interfere.

miketedeschi: how far away from each other are the ATMEGA328 chips?

I would said that the ATMEGA328p could be as far as 10 meters away from the Arduino UNO. But in most of the times they will be in a 5 meters range.

CrossRoads: How are they all connected? RS485? The master can send a message with an "address" of the slave the message is for. The message can be one way "Hey #74, do this" and wait for the slave to reply "#74, all done" and then talk to the next one. "Hey #75, got new data to send?", "#75, no", or "#75, 10 bytes, 0x00, 0x01,...0x09," If you let the slaves send randomly, there will be times where messages interfere.

I was not using RS485 because I thought that you could only have a couple of devices supported in the same line. Another issue is that the ATMEGA328p could send data to the Arduino UNO in any particular moment. What happens is that all the ATMEGA328p will have a motion detector, and whenever it detects motion it has to alert the Arduino UNO about it.

RS485 can have lots of devices, the MAX485 type chips allow numerous connections that do not interfere, as long as only 1 is transmitting at a time. Do you really need 200 motion detecters that are 5 meters apart? I would think there would be many hits from many devices for 1 event when they are that close.

I think the polling could be done quite quickly with just 2 byte messages if you are worried about latency. master: 0xAA## where AA is a sync byte, and ## is the slave 00 to FF address slave: 0xAA## or 0xAB## with the one bit indicating motion or not

At 115K, 800 bytes would be prety quick. Would also allow the master to confirm all slaves are still alive.