Introduction: System Status Traffic Light
Have you ever wanted to use a Traffic Light to signal if something is working or not? Well I know we have always wanted one in the office here at Proctorio.
We provide a service as well as use a number of third party services, all of which may or may not impact our daily operations. An example of this is: if a bakery's fryer is broken, they can not make doughnuts that day. However if the bakery only missed a shipment of rainbow sprinkles, they can still provide doughnuts to their customers.
We wanted a way to signal different types of these outages, so what better way to signal something than a Traffic Light? Our Traffic Light, believe it or not is 100% authentic and was gifted to us by a good friend, so you may have to do some hunting for your own.
(This is a recommended key components list, but does not include everything like tools, glue, paint, zip ties, etc.)
- Traffic Light - “Stop Light”, “Traffic Signal”, or even “Brake Light” if you prefer, although let’s pick one and call it a Traffic Light. You don't need one as fancy as ours, find a cheap one on ebay or even build your own!
- Arduino - We used an Arduino Yun. (this one is a little different than your standard Arduino; find out why we used this one and some other options later on)
- 5V USB AC Adapter - Depending on your setup, this may differ. Our Arduino Yun takes a micro USB connector and only 5V DC unlike a regular Arduino’s barrel jack (7-12v).
- 3 or 4 120v relays - Our lights are powered by AC, so we need a way to switch them on and off. We used a 4ch relay module, they are cheap and it makes all of the connections very easy using jumper wires and screw terminals. You will need 1 relay for each color. (We used the 4th relay as a master kill switch although this is not needed.)
- Small Box - Used to store all of the electronics. If you have space inside your traffic light this is not necessary. We used a 4" x 4" x 4" Junction Box screwed to the outside of the traffic light for easy access.
- Screw Terminal Block - Also known as barrier strips. Used for AC power distribution to make connections easier.
- Ring/Spade Wire Connectors - All AC wires are connected to terminal block using these. Keeps it clean and no soldering required, just need a crimper or something to crush them on to the wires.
- Assorted Wires - You will need some spare wire to hook everything up. I had all of these in my spare wires bin, but you will need some smaller gauge wires (M->F dupont jumper wires) for connecting the relay module to the Arduino, as well as some larger gauge wire for making the AC connections to the lights and relays.
- Prism Panel Light - Used to help diffuse the lights. Read on for more info.
- Velcro Strips - Used to mount the Arduino, relay board, terminal block, and AC adapter in the electrical box and makes them all easily removable.
Step 1: What's Inside?
First and foremost, this goes without saying but I’m going to anyways...
DON’T TOUCH LIVE WIRES OR TERMINALS
Keep it unplugged while you’re building it. It will save yourself from a nasty shock or possibly death, and also keep you from accidentally shorting something out. Be smart about it, you're a maker! :)
The trickiest part of this whole project was finding a square S2 bit for my hex driver in the bottom of our very messy tool box. Might make it tamper proof from your average thief scaling a light pole, but luckily I had one on hand. To remove the outer lenses from the light housing, there were a few phillips screws on the rim underneath the rubber gasket. Now we are into the light housing.
Isn’t it beautiful? Made up of a AC to DC driver board, a few high wattage LEDs, an inner fresnel lens, and an outer prism lens. Surprisingly each of the lights had a different number of LEDs inside with the yellow containing the most. The careful observer may have also noticed the red light is bigger than the green or yellow. Just like all the other lights in our office and kitchen, we are happy to keep the eco-friendly theme going with LEDs (yes, even our vintage filament bulbs are LEDs too).
Step 2: Blinded by the Light...
There was a small potentiometer on the driver board of each light (My best guess is this is to adjust the current from the driver main board to the LED board, but correct me if I’m wrong please!). Even with it turned all the way down, the brightness was still too bright. “I guess these things are made to be seen miles away” I thought to myself... The traffic light is far too expensive to accidentally fry a driver board or to spray tint the lenses. Something tells me I won’t be able to ask for a new one either. The more adventurous hacker could modify the circuit by limiting the current, or even do some PWM and make the lights dimmable. Heck, you could even eliminate AC all together and install your own LEDs.
I ended up just using a thin plastic “prism panel” light diffuser instead. Simply traced the inner lens to cut to the right size and added a few layers till it wasn’t blinding anymore and called it a day. One thing to mention, the prism panel shatters like glass when cutting it with scissors. I got the thinnest one they had which may not have helped, but I’d still recommend it as a possible solution because it made the light even more dispersed than it already was. The other thing to mention is, I noticed the green and yellow outer lenses had a slight angle to them. I flipped them to be pointing up instead of down, to help with the brightness as well.
Step 3: Tidy Up and Figure Out the Details
This wonderful device is going on top of our refrigerator in the kitchen/break room. So I rotated each light’s hood so that it looked "normal" laying horizontally rather than vertically. I then fed the main wires which require 120 VAC from each light, toward the right side (closer to the wall outlet in our case) through a hole that goes into the outer junction box. Be sure to leave enough slack to not pull the wires when each light is opened, and tidy them up with a few zip-ties.
Now is a good time to talk about mounting, as it may help you decide on the wire and box location. We had ideas for using galvanized pipe and flanges to make it look more realistic, but since it was going over the fridge, we decided to just bolt it straight to the wall through two holes in the back. We had a couple of these toggle bolts laying around which made it relatively easy and could easily support the weight. Our entire light was made of plastic, not metal (did you even notice?) which made it relatively lightweight, just bulky. It still required a friend to hold one side while the other screwed it into place.
Step 4: But Wait! You Can't Mount It Till You Wire It Up Right?
It's probably easier to wire it up before you mount it. Our box is screwed straight onto the outside so it didn't matter much, just be sure to paint it first if you choose to. Since the AC wires were short, it was easier to build the terminal block then wire up the relays while it was mounted. This was probably the most time consuming part. It may have been easier to do with a few wire caps, but those things just don’t look this good and I’d much rather do it right the first time. Looks complicated but let's break down the details:
The main AC lines from the wall outlet come in through a hole into the light/box and go to the two center posts on the 8 terminal block (don’t forget this! otherwise you will have to undo it, feed the wire though, then rewire it again…). Be sure to tie a knot or wrap some electrical tape around the wire inside the box to keep it from pulling out as well.
The right side of the block in the diagram is the hot side (black) and the left is the neutral (white). All of the neutral wires are connected together including each light and the AC adapter. I would recommend using terminal block jumpers (the store I went to was out, so I used short wires and connectors instead). The hot side is where things are a bit different. The AC adapter is wired so that the Arduino is always on. A hot wire from the center goes straight into Relay 1’s “COM” (common -> center screw post). This relay is our kill switch, but again this relay is not necessary (You could modify the code to just turn off all 3 relays and possibly use the 4th for something else. Modify the schematic by using a block jumper and connect each relay’s “COM” to the hot side instead). From there, Relay 1’s “NO” (normally open -> |_ \_|) acts as a switch for the hot side’s right 3 posts, which are all jumpered together. These are then wired to each light's relay to “COM”, and then each relay’s “NO” is wired to each light. The last step is to connect each “IN” pin on the relay module header to your Arduino’s digital output pins. The VCC and GND on the header will also go to the Arduino’s 5v and GND to power the relay module board itself.
(One thing to note: There is a jumper on our relay board that will use the Arduino’s power connected through the VCC pin to trigger the relays as well as power the relay board. The Arduino does not alllow a lot of power pass through itself, even if your AC adapter has plenty of current. You can jump this jumper but if the amperage isn’t high enough to trigger all of your relay’s at once, you may need to splice power from your AC adapter or provide a higher current/voltage within the relay’s specs directly to the JD-VCC pin instead).
Step 5: But What About the Arduino???
The most important part about this project is the Arduino. The Arduino Yún is a microcontroller board based on the ATmega32u4 and the Atheros AR9331. This isn’t your standard $10 Arduino; this little guy will run you $60+ but it’s got a ton of features that come with the price tag. The Atheros processor supports a Linux distribution based on OpenWrt named OpenWrt-Yun. The board has built-in Ethernet (with pins to supply your own POE module), WiFi, and even a MicroSD slot. What makes this Arduino special is it can communicate with the Linux distribution, making it a very powerful networked “computer” with the flexibility of an Arduino. Overkill? Maybe for this project, but the same goal could be achieved with a $2 ESP8266 WiFi Module or a Raspberry Pi and a little more complex code (maybe a project for the next instructable of internet connected things for the office :D). I’m not going to go over all of the other cool features of the Yun here, or how to get started with it. However if you are curious about the code, you’ll have to read it yourself over at GitHub. It is fairly well commented, so you will just need to adjust it for your specific case. Basically the Arduino checks for a value on a status page (a simple webpage that the server updates a value based on the information of our own status page), and changes color accordingly. It’s got a few timeout states and error states, as well as a debug mode. It also features the ability to accept commands from our local server to turn the stop light on and off or by visiting "http://_arduino's_IP_address_/arduino/_command_" instead.
Step 6: Close It Up and Call It a Day!
That's it! Your custom System Status Traffic Light is complete. Once the code is working and displaying your status properly, close up your access hatch. Hopefully we never see this thing show anything other than green... Feel free to post comments or questions if you have any!