Connecting Multiple Arduinos

Hey everybody,

I have a bunch of Arduino minis that I am trying to figure out how to exchange data between. I've worked with I2C before however in this scenario I only have 1 wire directly linked and a common ground.

To elaborate a little more each arduino has an ID, and that board can be connected to up to 4 other boards each one through a different wire. After each board is connected I need to pass the IDs between them so that each board knows who it is connected to.

I haven't gotten I2C to work for two reasons, the first is that it requires 2 wires, and the 2nd being that it requires known addresses. I don't have either of these luxeries.

I haven't been able to find useful information about using the Dallas 1-wire between 2 'masters.'

Has anybody done this before for have any suggestions about how to attack it?

You might have to roll your own solution here.

Set up a four wire "bus":

1 - GND
2 - CLOCK
3 - DATA
4 - CTS

Note - you may need a terminating resistor at each end of the "network", depending on distance between the devices (I think between DATA and GND, not sure, though).

The following procedure is likely full of holes and bugs, but the idea is there (you are going to have to come up with a system; this is just for an idea of how to approach things, and -not- an actual implementation):

Each Arduino on this bus would pick a random delay time. At the end of the delay, each Arduino would check CTS; if it is HIGH, then they go into LISTEN mode; if it is LOW, then the first Arduino that sees it as LOW brings it HIGH, then bit-bangs a HELLO signal to the rest, then drops CTS to LOW.

If any others are actively listening (waiting for the CTS to go LOW), and they see the HELLO, then they would know that when CTS goes LOW, they need to randomly wait a period of time, and the first one to transmit brings it HIGH, and responds with an ACK (acknowledge), and perhaps its random ID, then drops CTS LOW.

If the others see an ACK and an ID, then they know that ID is taken, and if theirs match, they need to pick another one, and use it when they send.

Now - this scheme won't be able to tell who is connected to who, but it (well, something similar to it - as I said, the above it likely buggy as hell) will eventually work to resolve the addresses for each Arduino on the network, and other Arduinos could be connected and join in, up to some arbitrary number of devices (there are going to be electrical limits that will limit this network severely, most likely).

To connect things together, use RJ-11 and twisted-pair CAT3 phone line.

Hope this helps, or at least provides inspiration to someone...

:slight_smile:

Thanks for the reply! That is something I was looking at, but I was given a mechanical limitation that each unit has those 4 connections to one and only one other unit. So kind of like a 4-legged animal with the body being one node and the feet being the others.

If each node can only be connected to one signal other node, then you can only have two nodes, right?

If you mean, instead, that you can only have a single connector, then that's ok, too - use a four screw terminal strip, and screw the wires down and daisy chain them.

Alternatively, use a single RJ-11 jack, but use daisy chained RJ-11 cables (where each plug, except the end nodes, have two cables exiting), or use RJ-11 dual-port adaptors (for phones, usually).

I am sure you can think of other methods...

:slight_smile:

An update on what I've done. I've not come up with a good way to do single wire arduino communication, so I went with software serial. (Now I have to convince the guys doing the mechanical design that it's needed, but that's a whole different ball game...)

Short of writing a 1-wire from scratch, I'm pretty happy with how things came out. I may try to add serial buffer space so I don't have the sync lag, but that's negligible.

I'm not sure if the common ground is needed anymore. I'll do some testing tomorrow to see if I have floating voltage problems.

Thanks again to all the posters here, it's a great resource.