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!


Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7:30pm ET! To join, head over to YouTube and check out the show’s live chat and our Discord!

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

Join over 38,000+ makers on Adafruit’s Discord channels and be part of the community! http://adafru.it/discord

CircuitPython – The easiest way to program microcontrollers – CircuitPython.org


New Products – Adafruit Industries – Makers, hackers, artists, designers and engineers! — New Products 11/15/2024 Featuring Adafruit bq25185 USB / DC / Solar Charger with 3.3V Buck Board! (Video)

Python for Microcontrollers – Adafruit Daily — Python on Microcontrollers Newsletter: A New Arduino MicroPython Package Manager, How-Tos and Much More! #CircuitPython #Python #micropython @ThePSF @Raspberry_Pi

EYE on NPI – Adafruit Daily — EYE on NPI Maxim’s Himalaya uSLIC Step-Down Power Module #EyeOnNPI @maximintegrated @digikey

Adafruit IoT Monthly — The 2024 Recap Issue!

Maker Business – Adafruit Daily — Apple to build another chip at TSMC Arizona

Electronics – Adafruit Daily — SMT Tip – Stop moving around!

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.