Help With Comms and multiple Arduinos

Howdy. I needs some help in figuring out the best way to achieve what I am trying to accomplish. I have been trying different approaches, but I can't seem to find anything that works as expected. I currently have many Mega 2560's(6+) and I want to chain them all together, or at least have a master and many slaves, but I need all the slaves to be able to communicate to master (for example on a button press) and the master should be able to communicate at anytime. The max distance from Arduino to Arduino is anywhere from 2 - 6 feet. The "Master" also has an ethernet shield. So Far the ethernet and UDP is up and running just fine. The issue is with any full duplex comms down stream. Any Help or ideas would be appreciated..


It sounds like you are looking for a wired solution as opposed to a wireless solution. I've no experience of using I2C off board as it were, but others on the forum have used it over several 10s of ft.

If you don't mind some additional hardware, then you could use RS485 running off one of your hardware UARTs on each Mega. The modules are quite cheap an are available on ebay or AliExpress in packs of 5 or 10 or more.

A master/slave setup is easy to handle - just poll each of your slaves in turn to see if the button has been pressed.

Please research what the concept of "Master - Slave" stands for. Your description is plenty of masters. That is more like the concept of Ethernet. Take a deep look at Ethernet strategies and demands.

I don't understand what you are asking for, if you have Ethernet you have the means for them to talk to each other.

Don't forget that UDP is lossy, there is no guarantee that a packet will be delivered, or that it will not be duplicated. You have to take this into consideration with the data you send.

Although it's a bit prehistoric, RS485 makes a very easy, wired, multi-drop network, and it might be easier to understand than other networks.

I've used an RS485 shield from DF Robot (RS485 Shield For Arduino -DFRobot) for a 10 drop network. A 3 wire cable interconnects all the Arduinos with the 485 shields installed. They are physically wired in parallel. The network works out to 25 m or more, at speeds as fast as anything the MEGA can do. I've put a DIP switch on each shield, and each shield gets an address thereby. Each MEGA reads the DIP switch to find its local address. You create some sort of serial protocol; the easiest is to define a 'master' which then sends a question down the line to each slave. The questions can be asked at a considerable pace (1,000/second??) so a switch closure can be picked up fairly rapidly. Alternately, a slave can transmit a data frame at random, but the slave must read its own data frame. If the read data frame is corrupted, that means somebody else 'stepped on' your data frame, so define a delay based on the (DIP) address and re-send the frame.

It's quite straightforward, despite my messy description of it!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.