May 29, 2015 AT 12:00 am

From the forums: “Lan of things” project is a simple way to drive many Arduinos from a Pi #piday #raspberrypi @Raspberry_Pi


Thanks to dcfusor from the Adafruit forums for posting up his great project! Check out even more information and photos of the build here.

This is working so well for me in my “Lan of things” project, I thought I should share it back to the community. While not “perfect” nor designed for very long runs, this protocol and hardware trick lets you have many arduino slaves from one master (I’m using pi here for that). I could have designed this far fancier, but simplicity rules for my own uses of this, so this is about as simple as it gets. It has the advantage of ignoring the little spit of garbage that comes out of the pi serial port when booted or connected to by say, one of my perl programs on the pi. I’m using only human-readable ascii myself, but all values 0-255 are possible in most of the fields. Real engineers don’t consider the glass half full/half empty – they make the glass the right size, and that’s what this is – for long runs, get into RS485 or similar…this is few-parts, small code – the right size for lots of uses.

The layout is quite simple. The first character is the “slave unit ID” – for a few, I’m just using 1-9 for that, but you could use anything.
The next character is whatever command you want to send the slaves, only the one with matching ID will actually get it. If you wanted to extend this (would be easy) that command could contain further data, I’ve just not had a use for that so far, so it isn’t in the provided sketch (which is meant to be added into your stuff via cut and paste and modified for whatever commands you want). A triggers the slaves to check out the command and maybe do it if it’s for them and one they recognize. Otherwise they simply ignore traffic from the master.

Both pi and arduino serial ports are “high” when resting – the stop condition. With a strong buffer (and this one is superman) – a pi can drive quite a few arduinos, and in fact if there’s a problem it’s the fact that this buffer is so strong it can more or less power up the slaves via their protection diodes. You may want to add a series resistor on each one to prevent that – series terminate the transmission line. I’m doing this successfully at 20’s of feet at 115200 baud with no issues, other than taking care to keep the respective grounds “close together” via fat wire, and alternating signal wires with AC grounds (eg ground and power) in cheap telephone cable or flat cable.
If you have extra wires, make them ground. In my use, I also send +8v from a switcher off my UPS batteries to power the slave arduinos, and let them use their series regulators to get precise (or at least stable) 5v, since the arduino a/d uses that for a reference, and I do use those.

Here’s the hardware schematic:


Read more.

998Each Friday is PiDay here at Adafruit! Be sure to check out our posts, tutorials and new Raspberry Pi related products. Adafruit has the largest and best selection of Raspberry Pi accessories and all the code & tutorials to get you up and running in no time!

Check out all the Circuit Playground Episodes! Our new kid’s show and subscribe!

Have an amazing project to share? Join the SHOW-AND-TELL every Wednesday night at 7:30pm ET on Google+ Hangouts.

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Learn resistor values with Mho’s Resistance or get the best electronics calculator for engineers “Circuit Playground”Adafruit’s Apps!

Maker Business — How Intel Makes a Chip

Wearables — Go magnetic

Electronics — LED colors: what they tell you

Biohacking — Brainding – Circuit Bending Using an EEG

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at AdafruitDaily.com !

No Comments

No comments yet.

Sorry, the comment form is closed at this time.