Introduction: Yet Another Arduino 110v Power Controller

Picture of Yet Another Arduino 110v Power Controller

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).

Step 1: Assemble Materials/Review Plan

Picture of Assemble Materials/Review Plan

Tools Needed:
Needle Nose Pliers
Wire Cutters and strippers
Screw driver
Soldering Iron
Multimeter

Materials:
Deep metal 4 gang output box and cover
Wire clamps
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
Wire Nut

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

Picture of Obligatory Warning

Warnings:
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

Picture of 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

Picture of 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

Picture of 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

Picture of 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.

Comments

TerryKing (author)2011-04-26

Lots of information on Arduino power control here:

http://arduino-info.wikispaces.com/ArduinoPower

Regards, Terry King

terry@yourduino.com

maewert (author)TerryKing2011-04-27

Very nice site, Terry, and well worth the read for those new to the subject as the site you linked provides a a detailed overview and excellent descriptions of the issues involving microcontroller control of high power electrical loads.  Also the commercial boards the site features seem to have good value for the price and are worthy of consideration in home projects.

Best Wishes
Mark.

bitastico (author)2015-01-07

How can i make it respond based on a ping response?? would be nice for remote network equipment that freezes up.

maewert (author)bitastico2015-01-08

bitastico> you would need to add an arduino that either detects the locked-up condition itself or waits for you to ping it when you detected the lockup. The Arduino would then power down the device for a specified amount of time and then power it back up again. Note that since this is mostly-always powered - you may want to reverse the logic on the power pins so it takes activating the relay in order to remove power from the device instead of the way I've shown it here.

Best Wishes.

threader000 (author)2014-10-11

Thanks for this great article. You mention, "Solder the signal ground wire and the wall-wart ground wire to pin 9 of the ULN2803A". The wall wart only has 2 wires (red/black). Should I solder the black to pin 9? (I assume red is positive.) Thanks.

Drdray1 made it! (author)2014-04-07

Great tutorial. I did my own variation but the arduino is powered by a transformer inside of the box. Next I'm going to install a smaller arduino so I can put a cover on it.

maewert (author)Drdray12014-04-08

Beautiful Job there!
An Ardweeny is smaller/cheaper but doesn't do its own power leveling so you'd have to use clean 5v if you want to use that. RFduino's look interesting but I haven't used them.
Best Wishes!

samf48 made it! (author)2014-03-12

Needed a remote kill-switch for my CubeX 3D Printer (which goes berserk often) for overnight builds when I'm away from the printer. I also have a network camera watching it so I can see if the build has failed. At that point, I will just remote kill the printer so it doesn't waste any more plastic. I am getting a wifi shield so I don't need a computer hooked up to the Arduino.

Nice work Maewert!

maewert (author)samf482014-03-12

It looks like a very nice job there!

Best Wishes.

samf48 (author)maewert2014-03-31

I've got a question for you maewert. If I need the power on for a long time would it be better to wire the relays as normally closed so they don't burn out?

maewert (author)samf482014-04-01

It sure would! If the thing you are powering is most always ON and seldom ever OFF then hook up the power through the NC contact on your relay. Just remember in the code now you have to set your control pin HIGH to turn the device OFF. Good Comments in the code will help you remember this change.

Best Wishes!

SuperTech-IT (author)2014-02-27

HAHAHA!!! Love the disclaimer!

I may steal that later.

bdjumakov (author)2013-12-05

For charging try mini usb ipod charger (example link http://www.ebay.co.uk/itm/New-Mini-USB-Wall-Adapter-Charger-For-iPod-iPhone-3G-3GS-4G-4S-T5-/400551010680?pt=UK_MobilePhones_MobilePhoneAccesories_MobilePhoneDataCables_JN&hash=item5d42b36178) I just bought 2 and was looking some instructable just like yours. The case is that I want to switch lights instead of a power socket.

City Lights (author)2010-11-30

I would suggest to anyone playing with circuits that switches house main voltage to install a ARC Fault breaker at the panel or somewhere before your custom monkey business! This Is Not the same as a Ground Fault which saves You from getting electrocuted. Most electrical fires are started by Arcing. A small arc over time will carbonized where the electrical bounding has been broken or poorly made. Once carbonized, heat increases and increased heat can lead to Fire. Arc Fault Circuit Interrupters Saves Lives from Fires! ..and property and insurance hassles :) so play it safe and Happy automating!

maewert (author)City Lights2010-12-01

I was not aware of these.  Sounds like a very good idea!

collinIT (author)maewert2013-09-12

I am new to all this. Would this be necessary for me to actively use this in my home?

maewert (author)collinIT2013-09-13

I'm not sure whether you are referring to the switch or to the ARC Fault breaker. Although I show you how to do this instructable, many people would probably feel more comfortable with a store-bought version like the one at Maker Shed:
http://www.makershed.com/PowerSwitch_Tail_II_p/mkps01.htm
Thanks,

Mark

collinIT (author)maewert2013-09-16

Hi mark, I am refering to the ARC fault breaker. My initial question was, would I need to use the ARC fault breaker if I am using this instructable in my home.

I appreciate the link, in the interest of saving money, If I am using the store bought version would I need this ARC fault breaker?
Very much appreciated.

maewert (author)collinIT2013-09-17

I would think that the store-bought version would include the necessary safety features and therefore you would not need the ARC fault breaker, but understand I am not a home fire safety expert, etc. so be sure to do your own research!
Best Wishes

globrite (author)2013-07-11

A nice alternative is to use a Wattstopper power unit which is UL approved, has zero voltage switching and as a bonus has DC output at about 150 mA to power your controller. One such unit (B-120 EP) is available from Amazon for about $15. - Enjoy.

maewert (author)globrite2013-07-11

I can not recommend the product you identified. While I always want to identify good alternative solutions, however, I am not convinced that the product you identified is actually a suitable alternative. The product does provide 24 VDC which can be used to power other devices as you suggest but it only supports one relay whereas my solution controls four outputs using TTL logic levels.
(I also notice that you have provided twelve comments, nearly identical to twelve instructables relating to power control all on the same day which makes me suspect that you have a particular interest in promoting the particular product you identified.)
Best Wishes...

SuperTech-IT (author)2013-05-29

I prefer driving a Triac output optocoupler into a Triac.
Especially for things you're going to be constantly switching like stage lighting controllers etc. You just need to be sure the triacs can handle the load you're putting on them.
When running a lighting controller, the clicking of relays would be annoying, plus you get into contact arcing issues as well as mechanical wear.
Of course there are cons with triacs too, such as inductive load limitations, but for my needs, they are the better choice.

maewert (author)SuperTech-IT2013-05-29

You are absolutely right. I've had had some difficulty with using traics with CFLs :-(
The lighting controller I demonstrated was just an example and surely one would not use the circuit to flash a light as in the demonstration as the relay noise was intense (but also very satisfying ;^). For some applications an old-school relay is the simplest and best solution - but not always, as you pointed out.

SuperTech-IT (author)maewert2013-05-29

But with a zero-crossig detection circuit, you could actually make your arduino DIM incandescent lights, which is really cool. Can't do that with a relay (well, maybe you could, but honestly, you'd kill the contacts in no time).
If you REALLY know what you're doing, you can even dim fluorescent lights, but you need either a really good, or slightly modified ballast.

maewert (author)SuperTech-IT2013-05-30

PWM'ing a relay in order to dim an incandescent light would be crazy indeed!

altoidsfreak (author)2012-08-14

If I did use a cell phone charger, how would I do this? I am also confused with using a wall wart. Do I have to cut the end off of the cord?

maewert (author)altoidsfreak2012-08-14

You can use it either way.  Just be sure it provides the voltage and the current you need.  If you purchase a mating connector then you can plug the charger into the connector and wire the connector to the circuit.  Otherwise you can cut the connector off the charger and wire the charger directly.
Best Wishes.

ringai (author)2012-08-09

This was interesting. I might suggest, though, that you make use of relays that will handle 15Amps.

Also, the NM wire clamps should both have bushings on the inside. They run about USD$2 for a five pack at the local big box. The bushing keeps the clamped wires from chaffing against the edges of the clamp on the inside of the junction box.

Rich1953 (author)2012-01-05

Nice write up, and a fun way to get into power control. Also could easily be expanded. If you want to bring the power supply requirements down the relay could be replaced with a Photo-Triac
This is a type of switch to control AC current with an LED.
A solid state relay would also work. but that would be for a more permanent instillation

maewert (author)Rich19532012-01-06

Thank you.
Yes, I think you are right. I have used regular triacs (but not photo triacs but i understand the concept :-). I prefer the 'solid' on and off a relay provides at the sacrifice of reliability as the relay's physical parts wear out much sooner than the triac. I have had problems of leakage current using triacs - a CFL bulb that would flicker a little bit when it should have been OFF when under triac control.

Thanks again!

Best wishes

fluxor (author)2011-04-30

Try using a tiny cell phone charger. I did in one of my projects. They are switching supplies and are quite small, but will output 5v anywhere from 500mA to 1A depending on the unit.

Voltamps (author)2011-01-14

An excellent and well documented instructable. How about adding the script for completeness. I have done lots of electronics projects but am new to the arduino so any help with programming would be really welcome.

Many thanks.

maewert (author)Voltamps2011-01-15

Voltamps,

If I were you I would begin my using the BLINK example program that comes with the Arduino environment. It will show you how to blink an LED or to 'blink' the power outlet in our case. This will help you debug your circuit.

Other than this the code would depend on what you want to accomplish, such as turning on a lamp when an infrared beam is broken, or turning on a heater when the room gets below a certain temperature. Each of these examples would be possible but would take additional hardware.

Best Wishes.

w0rm5 (author)2010-11-13

Very Nice instructable, can I program the code and add it directly to the arduino? So I can work without the computer?

maewert (author)w0rm52010-11-14

Yes,  an Arduino can easily provide the signals to control the relays.  In the demo I used the PC only to program (and run) the Arduino which provided the signals.

Computothought (author)2010-05-19

nte2018 = uln2803. if you have some really old disk drives, sometimes they have them.

About This Instructable

83,378views

123favorites

License:

Bio: I'm an aerospace engineer by trade but am interested in astronomy, robotics, CNC machines, Arduinos, you name it.
More by maewert:Long Term Food StorageColor Changing Crystal Staff for CosplayAdvent Calendar Box
Add instructable to: