Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
UART - 1 Master + Multiple slaves
I am experiencing difficulties with package loss and data overlapping (mixing of packages from several units) with UART.
- Because of low power consumption, the slaves wake up (at random intervals), perform their tasks and send the data to the master. The communication is therefore iniated by the slave.
- The master receives the data and sends an acknowledgement to the slave. The slaves attempts to send the data again for 20 times while no acknowledge is received.
- Slaves all send to the master, and do not receive each others data.
- The master sends to all slaves that are listening on that moment, programmatically I filter which slave should actually parse the message (The first two characters are the ID for which the message is ment for).
So far so good. But... I have package loss because of great distances. To overcome the affect of package loss I let the slaves sent their request/data again when the server does not acknowledge the data. No acknowledgement means noise in the line of communication.
I am using XBee (Zigbee) units (1 coordinator, the other two are end devices).
I use 9600 baud, even parity, 8 data bits, 1 stop bit and XON XOFF handshaking. RTS and CTS are not available (by default) on the XBee module (arduino shield), so no hardware handshaking in my case.
Most important question: How to prevent data packages to get mixed up. By mixing up I mean, unit 1 sends, but before all the bytes were sent, unit 2 send in the middle of it.
Thanks in advance. Hopefully I made myself clear, I want to keep it a relatively short post.