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.
Each 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!
We are angry, frustrated, and in pain because of the violence and murder of Black people by the police because of racism. We are in the fight AGAINST RACISM. George Floyd was murdered, his life stolen. The Adafruit teams have specific actions we’ve done, are doing, and will do together as a company and culture. We are asking the Adafruit community to get involved and share what you are doing. The Adafruit teams will not settle for a hash tag, a Tweet, or an icon change. We will work on real change, and that requires real action and real work together. That is what we will do each day, each month, each year – we will hold ourselves accountable and publish our collective efforts, partnerships, activism, donations, openly and publicly. Our blog and social media platforms will be utilized in actionable ways. Join us and the anti-racist efforts working to end police brutality, reform the criminal justice system, and dismantle the many other forms of systemic racism at work in this country, read more @ adafruit.com/blacklivesmatter
Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.