The Communication Predicament

Picture this. You have a Raspberry Pi. You have not one, not two, but THREE Arduinos you want to control. Don’t panic just yet, we’ve been there too, and I’m about to give you the inside scoop on how we solved this issue.

Initially, you might be inclined to say something along the lines of — “Hey, I’ve controlled Arduinos using serial before, that seems simple enough, right?” I’ll direct you to an excerpt from a Sparkfun article on communication methods.

“Because serial ports are asynchronous (no clock data is transmitted), devices using them must agree ahead of time on a data rate. The two devices must also have clocks that are close to the same rate, and will remain so–excessive differences between clock rates on either end will cause garbled data.”

Doesn’t sound so rosy, does it? The issue of consistent clock rates is somewhat questionable with the Raspberry Pi, which has some issues with keeping consistent a consistent clock. Beyond this, the Raspberry Pi has but two serial ports, which won’t be sufficient to control three Arduinos. You’re probably also going to be using these for other input/output devices.

At this point, I think we’ve effectively crossed serial communication off the list. What’s next? How about some SPI — which stands for Serial Peripheral Interface.

Right away, we can see there’s one major drawback to SPI — the sheer number of pins it takes to implement. Connecting a single master to a single slave with an SPI bus requires four lines; each additional slave requires one additional chip select I/O pin on the master. The rapid proliferation of pin connections makes it undesirable in situations where lots of devices must be slaved to one master.

Enter I2C. The best of both worlds. Here’s a quick schematic to give you an overview.

I2C requires a mere two wires, like asynchronous serial, but those two wires can theoretically support up to 1008 slave devices. Also, unlike SPI, I2C can support a multi-master system, allowing more than one master to communicate with all devices.

Both the Arduino and the Raspberry Pi support I2C, so that’s what we’re moving forward with for now. There’s still some uncertainty as to whether it will work over long distances, as I2C is generally used in very close proximity.

One Raspberry Pi to rule them all, where ‘them all’ is 3 Arduinos.

--

--

Patrick Huston
Principles of Engineering — Falcon

Chief Technologist | Rocket Talk Enthusiast | Series F (Fun) Bootstrapped Crowdfunding Entrepreneur