LED Bar Graph with Slack Chat Control

The end goal of this project was to project a bar graph.  Sure, any LCD screen/monitor would do and be WAY prettier.  But what if you could hang this on the wall?  What could that look like?  As a passive display (one that hangs out in the corner of your eye), could this be useful?

I had a chance to play with Adafruit’s NeoPixels at the 2017 CodeMash.  They were fun and easy to work with!  Bonus:  They can be daisy chained and individually addressed.  This means you can string a bunch together and control the color of each one individually.  Adafruit sells them individually or in strips.  I grabbed the 30 LED strip one:  https://www.adafruit.com/product/1460

You will need some additional parts.  I’ll save writing all of this out by linking to Adafruit’s great docs:  https://learn.adafruit.com/adafruit-neopixel-uberguide/basic-connections.  Basically:  LED light strip + 1 resistor (for circuit protection) + 1 capacitor (for circuit protection) + power supply with some amps + Arduino (to control the lights).

Wire everything up then install Adafruit’s sketch for the Arduino to verify the lights and wiring and you get something like this video (1 out of 2 cats were amused):

I opted to have the Arduino handle the LED control since it looked like Raspberry Pi would be a bit tricky to get working.  Plus, I had other plans for the Pi, which included it controlling the Arduino.  For the Arduino, I installed a flavor of Firmata which included NeoPixel support (https://github.com/iamvery/artoo-neopixel/blob/master/firmata/StandardFirmata-NeoPixel.ino).  For the Pi, I wanted to use Python but I couldn’t get anything to reliably work.  Node is a bit of a hassle at times but this time worked out pretty nicely when I used this library: https://github.com/ajfisher/node-pixel.  I verified the Pi was talking to the Arduino and able to control the lights.

Next up was getting a script setup to display a bar graph and pull down some interesting data to graph.  This was done in Python.  The data could be anything mildly interesting.  For this project, it would be the number of users on a web site, updated near realtime (updated once a minute via cron, so not quite realtime).

Raspberry Pis run great on their own without a monitor or keyboard.  But without those, they’re tough to control and interact with unless you remotely connect to them, say over SSH or remote desktop.  This is great if they have a static IP.  They’re easier and more flexible when using a dynamic IP.  So to get the IP, I setup Hubot (Node again) and have Hubot connect to Slack.  Get this wired up and now you can ask Hubot “ipaddress” and it’ll return it, allowing for an SSH session or whatever you like.  With Hubot running, a few additional commands were added to control either the entire light strip or individual LEDs.

End result. Markers to indicate quantity added shortly afterwards.

 

Leave a Reply