Ways of interconnecting Arduinos

Hi,

What possible ways are there of connecting a series of Arduinos together so they can share information? i2c seems to be one-to-one, as is serial; I guess you could use both simultaneously. How about SPI?

Obviously the ethernet shield would work but the expense goes up.

I can't find this among the FAQs or by searching, so apologies if this comes up regularly.

Thanks, ickphum in australia

Are the Arduinos in close proximity to each other?

A few of the top of the head...

  • Serial (TTL)
  • Serial (RS232)
  • Serial (RS485)
  • Serial (I2C)
  • Serial (radio)
  • Ethernet
  • XBee
  • CANBUS
  • Pin-to-pin

As implied by PaulS, you'll have to provide more details if you'd like help narrowing the choices.

Another very important factor is the form of communication.

Is it with a dedicated master and a bunch of slaves, and all communitation initiated by the master ?

If every node should be able to talk to every node, then the protocol they use will be very complex, but i think that one of te Xbees support such a scenario.

xbee's offer a full mesh infrastructure with just a little configuration, if a lot of confusion.

RS458 is a variation on serial that allows multiple units to share one bus (2 wire cable for half duplex). You can do full duplex (4 wires) but its tricky.

Its rather simple to convert the TTL RS232 serial already on Arduino to RS485, its just a single cheap IC and a resistor in each end of the cable.

RS485 also runs over much longer distances than ordinary serial.

I2C and SPI are both meant to be used for (very) short distances.

But again if you need true mesh communication, the protocol needs to implement collision detection (two nodes try to send at the same time), this is kind of tricky.

If you can live with master / slave style communication, then RS485 is a good choice.

I2C and SPI are both meant to be used for (very) short distances.

That should be "very short" rather than "(very) short". As in "small numbers of inches/cm". Especially for I2C. It's a common newbie mistake to overlook the fact that both were originally designed to be used for connecting to other chips on the same board, or plugged into the same motherboard, and they very quickly run into the design limits when connected to even a few feet of wire. More often than not, unhappy things happen to people who try to use I2C or SPI the same way they might use, say, RS-232.

Another thing to keep in mind is that the Ethernet shields (and, I'm pretty sure, the WiFi Shield) use SPI to communicate with the networking interface. So, if you're thinking about connecting your cluster of Arduinos to the LAN, you might have to rule out SPI for interconnecting them, even if it's otherwise feasible.

Ran

  • Asynchronous communications using the UART.
  • Synchronous communications using SPI or I2C peripherals.
  • Communications using the digital IO pins under SW control.
  • Communications using an external dedicated controller chip (you'll probably need one of the above to communicate with the chip.)
  • Ethernet
  • CAN
  • Zigbee
  • Bluetooth
  • IRDA

It's all in the details: who can send, who must receive, how complex does it need to be, etc. I2C has a broadcast function, BTW. Several async serial mechanisms can provide broadcast/multicast/multimaster capabilities; it depends more on the electrical level stuff. As an extreme example, you can run IP protocols over async (SLIP, PPP) and have all of the ip multicast stuff available, assuming you're connected to sufficiently powerful routers.

Hi, ickphum here again.

Firstly let me say how impressed I am by the replies given the sketchy nature of my first post (I was running out the door and just wanted to test the waters).

Physical issues; I think the separation will need to be at least 1m, so that appears to knock out i2c & SPI immediately. Xbee doesn't appear any cheaper than ethernet once you get the shield + antenna, so I'd think that was out unless I'm missing something there.

RS485 sounds intriguing; I haven't had a lot of thought about the network structure (master/slave, mesh, etc) but if this is reasonably easy to achieve it sounds like the best prospect. I want to connect the nodes dynamically and have the network "just work", so arriving at a master on a shared bus sounds a bit tricky, but it also sounds like a solved problem if I look around.

My background is software dev, although I have written C apps for an embedded device not dissimilar to the Arduino, so I'm somewhat familiar with the constraints. I can use a soldering iron...somewhat.

So; 1m separation of arduinos, master/slave is ok, easy-level hardware mods are ok. I think this points to RS485 but obviously are looking for your opinions.

Re RS485; I gather that the unit has dedicated serial hardware (referred to as TTL above) and can also use any of the digital ports for software serial (but other posts I've seen imply that software serial is trickier to use). Am I right in thinking the RS485 conversion involves the hardware serial port, and does this also imply that I'd use the standard serial library API as I would for RS232?

Thanks, both in advance and otherwise,

ickphum in australia.

Am I right in thinking the RS485 conversion involves the hardware serial port, and does this also imply that I'd use the standard serial library API as I would for RS232?

Yes. However you could use a software serial library API and using the same RS485 driver/receiver chip, have it work with any pair of Arduino digital pins. Also the Arduino Mega has avalible four hardware serial ports if required or desired.

Lefty

Hi, ickphum again.

With RS485, what limits are there on run length and number of nodes, assuming nodes are 0.5 - 1.5m apart?

Thanks.

With RS485, what limits are there on run length and number of nodes, assuming nodes are 0.5 - 1.5m apart?

At the refinery I worked at we had RS-485 links running over 1,000 ft or more to maybe a dozen nodes. We did use good quality shielded wire and ran it through conduit.

Lefty

I think that it is actually up to 4000 ft. and 32 nodes if you use twisted pair cable.

I have software serial (newsoftserial any way) running reliably over 50 metres at 9600 baud. A couple of spare wires in the cat5 cable also feed the remote arduino with power from the main one, which saves rigging up another power supply. OK for basic sensors, but large current demands are out due to the resistance of the cable. I get around 4.75 volts at the far end on mine which makes it as good as some USB power setups (arduino, a few indicator leds, digital thermomters and reflective object sensor - around 40mA) . Other than the pain of running the cable, its cheap and fairly easy.