This Instructable shows you how to build a four-gang outlet box in which each outlet is controlled via an Arduino (or any other TTL level signals).
It differs from the other relay boxes in that it uses no circuit boards and has very few parts (one chip and 4 relays).
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Assemble Materials/Review Plan
Needle Nose Pliers
Wire Cutters and strippers
Deep metal 4 gang output box and cover
Two 15Amp outlets
Four 5v 10Amp relays (such as Jameco’s 843155)
A ULN2803A (such as Jameco’s 34315)
A 5volt – 500ma Wall Wart (such as Jameco’s 164101)
A length of 5-conductor wire (I used Cat5 cable)
Household current rated wire with a male three-prong connector at one end.
Miscellaneous wire and solder
5 minute epoxy
Theory of Operation:
The electricity flow to each outlet of a four-outlet household current box is controlled via TTL level signals (such as the output pins of an Arduino). Five wires are connected from the Arduino to the outlet box, four wires being connected to four Arduino output pins and the fifth to the Arduino’s ground pin. A separate 5 volt wall-wart is used to power the outlet box (the outlet box relay activation coils will consume nearly 500 milliamps and a separate wall wart is used here so as not to stress the Arduino power supply). The TTL control lines are wired to the inputs of the ULN2803A which can handle the relay coil current needs and also contains diodes to safely manage the back EMF produced by the relay coils when switched off.
NOTE: for simplicity the schematic only shows a single outlet connection. Repeat the wires for the other three relays and other outlets, using ULN2803A Pins 3 & 16, 5 & 14, and 7 & 12.
Step 2: Obligatory Warning
Household current can be dangerous to your equipment, both electrical and biological! Having control and power wire in the same enclosure can expose the connected circuit to damaging voltages in the event of part failures. I make no claims or warranties, etc, you assume all of the risk should you attempt this build. Those attempting this build are either knowledgeable or foolish, or as in my case, a little bit of both.
Step 3: Wiring the AC Portion of the Outlet Box
In US household wiring, the green wire is ground, the white wire is return, and the black wire carries the power.
I begin by breaking off the four metal tabs attached to the outlets. These tabs are used to secure the outputs in a different enclosure and are not used for the metal enclosure. The tabs have a little crease in them which helps the user remove them. Remove the 4 tabs from each of the outputs by bending them with the needle nose pliers until they break off.
Next cut the connecting bar on the ‘gold’ colored contacts. This bar allows the power to flow to both outlets whenever one outlet is connected and since our relays will power each separately we must cut this connecting bar or both outlets will receive power if either outlet is enabled.
Next add a small wire connecting the white terminals of the two outlets together. In my case I used a four inch piece of 12 gauge solid copper wire. I do this by striping and attaching the white wire to one of the outlets ‘silver’ terminals, then attaching the outlets to the metal faceplate such that the white wire is between the two outlets. This holds the outlets in their final position so that I can bend the white wire to the other outlet terminal and still be able to screw the wire to the terminal.
Next add a small wire connecting the ground terminals of the two outlets together just like we did for the white wires above.
Step 4: Relay Connections
I mix up a small amount of quick-set epoxy and I then epoxy the four relays to the backs of the AC outlets.
You may also epoxy the ULN2803A to a clear area on one of the relays. Be careful to remember the part’s orientation so you know which pin is pin 1, etc.
Be sure to wait until the epoxy is fully cured before proceeding. I waited 24 hours myself.
I then attached a black wire from the relay’s Normally Open (‘N/O’) output pin to the ‘gold’ outlet terminals. I did this by first attaching the wire to the outlet terminal and bending the wire into position so that the wire touches the terminal with no strain on the wire or the relay pin, then I solder the wire to the relay pin. I used solid 12 gauge wire to make these connections. You can use 14 gauge wires also which should be less stiff and easier to work with.
Next attach an 8 inch piece of black wire to each of the relay’s common pin. You can epoxy this wire to the outlet case as well to relieve the strain of the wire on the relay terminal pin. Again, wait until the epoxy cures before proceeding. (As you can see from my pictures, throwing caution to the wind I did not provide this strain relief.)
Next prepare the metal box by knocking out two of the punch out holes and installing the wire clamps. Feed the 3 prong male plug through one of the clamps and attach the green ground wire to the ground wire on the outlets. Now attach the white wire to the other accessible ‘silver’ terminal of the outlets. Using a large wire nut attach the four back wires to the black wire of the 3 prong plus. (Again I did not follow my own advice as I didn't use a wire nut, I soldered the wires together and used electrical tape to wrap up my soldierng mess.)
At this point you may use a generous amount of electrical tape to cover up any exposed wire which carries AC household current. If you choose not to perform this step you can easily get ‘bitten’ by the electricity should the 3 prong plug get plugged in while the box is not closed up. I did not do this here since I wanted to keep everything exposed for the project pictures.
Step 5: Connecting the Logic Circuits
Feed the wall wart power cord and the 5 strand wire through the second wire clamp on the metal outlet box. I used some spare Cat5 wire I had which contains 8 conductors and I cut the ones I didn’t need.
Solder the signal ground wire and the wall-wart ground wire to pin 9 of the ULN2803A.
Solder the +5volts wall wart wire to pin10 of the ULN2803A.
Solder the four control signals to pins 1, 3, 5 and 7 of the ULN2803A.
Solder one side of the relay coils to ULN2803A pin 10 (5 volt DC power). I did this by running a single wire from pin 10 to the relays in serial.
Solder the other side of each relay coil to pins 18, 16, 14, and 12..
Next connect the 5 conductor wires to the Arduino pins. The ground wire must connect to the Arduino ground. The four other pins connect to the digital output pins of the Arduino. Leaving the three prong plug unplugged, you can plug in the wall wart into a household outlet and use the Arduino BLINK program to test the circuit and to match the control wires to the outlets. You should be able to hear the relay click off and on when the output pin ‘blinks’.
Step 6: Final Assembly
Assemble the box and tighten down all of the wire clamps, etc.
I like to use an ohm meter to ensure there is no connectivity between the signal wires and the AC lines. With the 3 prong plug unplugged, connect an ohm meter to one of the three prongs and ensure it has no connectivity with any of the control and ground signals in both relay states (i.e. all relays deactivated and all relays activated). Repeat for the other two prongs of the three prong connector. Check also that there is no connectivity between the three prong connector wires. If all checks out you should be ready for a live test.
Plug the three prong connector into house wiring and actuate the relays. If you heard the familiar clicking of relays and no smoke was released and no sparks were generated then good deal. Now you may plug four electronic devices into the outlets and test to ensure that each one can be individually controlled.
Demo video at: http://www.youtube.com/watch?v=jNFfdMJ17v4
Step 7: Alternatives
If you use a wall wart as I did, you may consider using a 6 volt version. There is a 1.4 voltage drop through the ULN2803A and this will therefore provide the relay coils with 3.6 volts, which is just over the relay’s requirements (3.5 volts needed to pull in the relay). I was attempting to stick with the 5 volt source since it *could* be common with the Arduino 5 volt power supply. The 5 volt power works, but 6 volts would pull the relays in rather soundly and might be a better solution.
I did not actually like the idea of a wall wart. I would have preferred to use the Arduino power itself or to include a small 5v DC power supply inside the metal enclosure. I was not certain that the Arduino power supply could spare almost 400 ma of current and I could not find a small enough transformer to fit in the metal case. Maybe some of you will have better luck.