Building that thing I just built, but cheaper.
I recognize that my last post about a DIY Status Light the project had a total cost over $100 (and that wasn’t evening including SD cards, power supply, shipping & taxes). And that high cost wasn’t for core functionality, it was for aesthetics.
I wondered if I over did it, and how much it would cost and what we be involved, to build a status light for as cheap as possible. I quickly found the answer (from the store I frequent):
Building this out, you’ll notice in the images on this post, I’m using a breadboard instead of the Squid. I did this because I had all the parts of the Squid already from separate kits just not assembled. Note everything in the pictures used is the exact same as the Squid, the Squids just pre-assembled and the cheapest way to get exactly what is needed and nothing more.
Because there is no big led matrix panel, I found a normal phone charger or laptop can be used to power the Pi and light instead of a proper >2 amp power supply. This saved about $5-10.
This is a solder-less approach, so there’s some extra cost in getting the Zero WH instead of just the Zero W and the pre-wired RGB LED, if you know how to solder and have the equipment and can shop around for cheaper parts or cheaper shipping, you may further shave a few bucks off.
Of course you’d need to get creative on a way to mount this at a place appropriate for your use case. Thinking back to when I used to work in an office setting, this would of been great to have stuck the Pi to the rear of my monitor and put this LED at the top corner of my monitor.
Never using GPIO pins before, the code to control this light was way easier than I thought it would be. I had a bit of a curve ball as it took me a while to realize my LED used a shared anode, not a shared cathode (like the Squid is) as both kinds exist, but the code changes to toggle the two is minor. Here’s the script for both and the wiring mentioned inline to test it out (I used
$ pinout on my Pi to get the pin labelling):
# https://davidsword.ca/a-cheaper-diy-status-light/ import sys import RPi.GPIO as GPIO GPIO.setwarnings(False) # Note this is BOARD numbering. GPIO.setmode(GPIO.BOARD) redPin = 3 greenPin = 5 bluePin = 7 # set to false if using a RGB LED with common Anode. commonCath = True GPIO.setup(redPin, GPIO.OUT, initial=0) GPIO.setup(greenPin, GPIO.OUT, initial=0) GPIO.setup(bluePin, GPIO.OUT, initial=0) if commonCath: setOn = 1 setOff = 0 else: setOn = 0 setOff = 1 def turnOn(pin): GPIO.output(pin, setOn) def turnOff(pin): GPIO.output(pin, setOff) def main(): cmd = sys.argv if cmd == "busy": turnOff(greenPin) turnOn(redPin) elif cmd == "available": turnOn(greenPin) turnOff(redPin) elif cmd == "offline": turnOff(greenPin) turnOff(redPin); else: print("Not a valid command") main()
Edit this script if you’re using a common anode, set
commonCath = False. This script can be run by passing the status as a single arg:
python3 rgb-led-status.py <avaliable|busy|offline>. Example:
$ python3 rgb-led-status.py busy
Forking the busy server, or setting up a new Flask server to run the code for adjusting this light as shown in the code snippet wouldn’t be a big lift at all (though you’ll have to take my word as I’m too pinched for time to prove that).
This was a fun 30 minute project – and a good way to save $60+ if function is greater than form to you.
UPDATE: My good friend, after reading this post, informed me there’s much much cheaper ways to do this using a $2 ESP32 board. I can’t wait to try that out.