Software Engineer

Raspberry Pi Powered On-Air Indicator

· by jsnby · Read in about 4 min · (726 Words)
golang

On Air Light

On Air Light

Working from home during the pandemic has presented some unique challenges for my family. Lately the kids (and occasionally my wife) will interrupt me while in a meeting. I wanted some sort of way to indicate to them that I was in a meeting. Being an amateur radio operator, I thought an “on-air” indicator light would be fitting. I wanted to be able to control it remotely. I looked around online to see if there was one that would fit my needs, thinking I could use a smart switch to turn it on/off. About the cheapest I could find a light was about $60, and that did not include the smart switch. I decided I could build one instead for about half that price utilizing components I had on hand.

Hardware:

I had the rpi, wifi dongle, level shifter, USB OTG adapter, power supply, and LEDs in my parts bin left over from various other projects, so all I had to buy was the tea box and white acrylic.

I pulled the dividers from the tea box and used a chisel to remove the wood strip holding the clear acrylic in the lid. I then cut a piece of white acrylic to the same size. I disassembled the box, primed and painted it black. I reassembled everything, using a little wood glue to hold the acrylic into the lid of the box. My wife has a Cricut, so I designed a sticker and had her cut it out of red vinyl.

Wiring everything up is pretty easy. Adafruit’s tutorial outlines how to wire it all up.

I then moved on to writing some code. I created a python script that watches for a file to be present on the filesystem…if the file is there, it turns the light on. If the file is not there, the light is turned off.

I then wanted an API. I built a simple server in Go. The API is really simple…a GET to /on will create the file in the location that the python script is watching. A call to /off will remove the file, if it exists. I build a small UI with buttons to turn things on/off as well:

On Air Light

I set it up and explained to the kids and my spouse that if the light was on, I was in a meeting and only should be interrupted if it was something that needed to be immediately addressed. It worked well for both them and me. The only problem was I had to remember to manually turn it on/off. I put a couple of shell aliases to execute the curl calls to hit the API to make it simple to turn it on/off, but I really wanted a way to turn the sign on/off whenever I was on a zoom meeting.

My current machine is a Mac. I noticed when I was in a zoom call, there is an application called cpthost.app that runs, so I can just periodically poll and see if that app is running turn the light on or off. I wrote a little go program called onzoom to do this, but I didn’t want to have to start this up every single time I booted my computer. I used Automator.app to build an app that runs as a startup item that then executes my onzoom program, so now every time I log into my machine it’s automatically running in the background.

The system is working well. One thing I’m considering doing is extending the system to also be able to indicate if my wife is in a call. The WS2812 LEDs can be set to any color, so I was thinking that if I’m in a meeting I’ll turn the LED’s blue, if my wife is in a meeting I’ll turn them red, and if we’re both in a meeting, I’ll turn them purple. She works on a windows machine, so I’ll have to play around with that to figure out how to auto-detect if she’s in a zoom or webex meeting.

All of the code and the artwork can be found on Github.