120v switching

[Kenneth] built a 5v controlled power outlet inside of a junction box. We’ve seen plenty of projects that can switch 120v outlets using 5v logic for refrigerator controllers, lighting controllers, or grow systems, but they almost always use solid state relays to facilitate the switching. This iteration uses mechanical relays along with the necessary protection circuitry. The project is housed in an extra deep single-gang box and allows for individual switching of the two outlets. You can see this connected to an Arduino switching two lamps after the break.

I was looking into doing this as well. Problem I had is I wanted a low power application, solid state relays couldn’t handle the maximum load of the outlet (15A in north america I believe), but physical relays took a fair chunk of power themselves, 400mA for the ones I was looking at.

I know it’s probably a safety issue, but there needs to be a relay that only draws current for the actual switching, then stays there unless it’s switched back.

If you were going to put this in a wall, it would be better done in a junction box, separately from the plug itself, then run 14/3 to the plug. For one, it’s not fully accessible to the room. For two, no one expects to see extra electronics behind an outlet. From the electronics side, it’s a good solution. There are commercial alternatives (X10/etc) but this is definitely cheaper.

@Peter there is it is called a latching relay. some have two coils so a pulse on one will turn it on and a pulse on the other will turn it off. other only have one coil and one pulse will turn it on a second off.

“By the way, I certainly hope that this ‘hack’ is not ‘news’ for anyone reading this website.”

Actually, I was thinking just yesterday of how to do something very similar, but with DC. I’ve just ordered the parts, and this will be my first Arduino project. So, yes, this is ‘news’ to me, and I’m glad the editors don’t take the same elitist attitude!

This is a horrible build from a safety stand point. Cardboard, no fuses, no optical isolation, and if it burns your house down you’re out a house for violating your local electrical code. Your insurance company will laugh at you.

@Peter: The relay I’m using draws about 65mA at 5V, so the power consumption isn’t killer. A latching relay would be ideal.

@Hackius: I separated the two outlets so one is NO and one is NC, so both. The coil is de-energized with a low input on the control line.

About the NEC comments: I don’t show it, but the wire running out of the box is a 3 prong plug, so this is temporary wiring, and doesn’t violate the electrical codes as I understand them. I agree, I would NEVER NEVER NEVER put this in my wall. I just hacked this together to prototype stuff with my Arduino.

Other lacking safety measures aside, I don’t understand why people are complaining about the lack of opto-isolation. The relay is rated for 1.5kVAC separation between the coil and contacts, so I’d think my lack of care in routing is more at fault.

@polossatik
Wow, this is a new low for hack a day.
driving a relay with an arduino, you almost make it sound that a regular relay is more exciting than a ssr.
Anyways awesome “hack”
/sarcasm
Digikey has multiple ssr’s that source/sink 16 Amps of AC at 120/240V, you could even use those as dimmers.

Nice job Kenneth,
Sorry if it offends some of the 733T hackers here. I have a different approach if anyone is interested. It uses opto isolation and Triacs that can handle 8 A RMS and 70 A peak with a 400V rating. The boards I am using even have a header that will plug into a arduino as a Shield. I have had about 500-800 of these laying around for serveral years and I just finally got around to messing with them. You see them at my blog mendingthings.com.
Oh and to your point of not needing opto isolation, I have many stories I could share about relay breakdown leading to control voltage side melt down, so don’t rule out the need for isolation for a serious build.

I would love to read an article that is about what is “the state of the art” for electronic control of mains power – (Inside a wallbox. As in something that meets regulatory standards and doesn’t look shitty.) I know that wouldn’t be a hack – it would be DIYinAProfessionalWayADay.

Everytime someone says “there is a better way to do this”, they need to man up and post their solution to the web.

These types of relays which are shown on the photos are absolutely not suitable for direct switching of these types of load!

1. A standard Linde-type refrigerator motor has an enormoulsy high inrush current when switched on. This is caused by the popular choice of a low-impedance resistive phase shifting motor starter auxiliary winding.

2. The relay’s rated current applies to non-inductive loads only, and motor loads or similar are highly inductive.

@mosheen,
I will not argue theory with you. I will only state that Experience tells me magnetic isolation in the form of a relay is not sufficient to prevent damage to the primary circuit. This goes to Urich’s point about contactors. The spacing and design is such that the isolation is sufficient for protection as well as high inrush current. I don’t think that Kenneth’s intent is to install these in a wall for daily appliances or mass market them so he has an acceptable design. My comment was around a more serious build.

If it was built with SSRs you could do PWM dimming. I tried PWM (low frequency) with a relay, and I quickly fried a relay.

Why would you want to switch a refrigerator on and off? The built-in thermostat is good enough for me, and I don’t want my food going bad if something goes wrong with a 5V supply, arduino, or relay.

I am working on something similar for controlling lights (specifically, syncing to music), and I gave up on relays. I’m either going to do it with SSRs or make my own SSR. I plan on optically isolating it if I don’t use SSRs, (and maybe even if I do). I would never put it in the wall, even though it is build in a 4-outlet junction box (8 individual channels).

@Matt – If you’re brewing at home, the built-in thermostats in most refrigerators suck, particularly if you’re using a chest freezer for conditioning. In that case, you can’t get the freezer ‘warm’ enough for the proper conditioning temp.

@odin:
I’m an industrial electrician and a control specialist. I’ve seen contactors and relays, and just about every other type of device charred to a crisp. A relay does jack for isolation when it burns up. Yeah it can handle 25kva blah, blah, but when the casing turns into carbon, a conductor, all bets are off. The opti is to protect the control side and the user. PLC’s have optical isolators on every card just for that reason. No sense killing the whole rack when a trace burns clean off of a relay board.

Sorry I was talking to @odin not you and we are making the exact same point. I suspect those in our background have seen many toasted control circuits because of relays turning into carbon, copper and silver blobs. Not much isolation when that happens.

This project seems to pay a little more attention to safety concerns than some of the other line-voltage “hacks” I’ve seen here, but I’d like to share a few comments.

I agree that a solid state relay might be a better choice than a mechanical relay. I would mount it in an aluminum outlet box, so that the relay can dissipate heat into the housing. Ground the housing for safety.

Solid state relays switch on zero crossings, so they are much quieter, electrically speaking. This is very important if you intend to do any kind of bang-bang control.

One possible downside to solid state relays is that they will *not* switch properly if they are not loaded sufficiently.

Whether you use a mechanical or solid state relay, one thing is clearly missing from this design– a fuse in the 110 “Hot” lead. A fuse goes a long way to protecting your switch gear, maintaining isolation, and protecting your home from fire.

Here is my version using SSR, though I agree as with mine not the safest solution (not using that implementation at the moment) though still fun to turn stuff on and off with serial communication and better than the typical spliced extension cord with live hots for all to see and touch.

Good job. I would replace the cardboard and use a proto board so you can solder the parts to the board. They only cost about $3 for one that will do what is needed here.

I would also place it in a metal wall box instead of plastic so if something like a fire were to occur you have better protection as well as the casing being grounded for shock prevention.

People saying, ‘use a solid state relay’ need to realize that people have been using this circuit for decades and it is in use in millions of places for a reason, it works and it is safe. The relay is just as good isolation as a optoisolator and often more reliable than solid state relays because it produces no heat and has a very low parts count. Television sets have used this for over 30 years when turning on and off and I don’t see homes going up in flames because of it.

One nice hack you can do with this circuit is to buy a cheap clock or clock/radio. Use an extension cord and cut one of the wires , leave the other wire intact. Inside the radio attach the circuit used here to the alarm function(speaker or piezo) and run the cut wire of the extension cord through the relay. You now have a device that can turn anything on at preset times and depending on the clocks functions turn it off after 15 minutes or 1 hour. I used it for years to wake up to my tv . This was back in the 80’s way before tv had alarm functions.

That hot-melt glue construction could be a recipie for disaster – while the circuit design itself is fine (the relay providing adequate isolation), it wouldn’t take much for one of those components to pop loose and potentially short the high voltage side to the control logic side, leading to destruction or harm.

Having used a decent duplex box and such, it seems odd to skimp on a simple protoboard or other suitable construction method.

I would use a solid state relay. Just do a search on ebay. The last one I bought was $6.99 and that was with shipping. It can handle 25 amps and can be switched with 3-32VDC and provides optical isolation. You can drive it directly from a port on the Arduino. It will take a couple of weeks to arrive.

Why do this when there are tons of pre-compiled solutions, that are much safer?

(I know the “Why do this” question is the anti-thesis to hacking but I really think the ready-made option is better.)

X10 products have been selling switch 110v outlets based on a form of analog powerline networking that can interface with a pc (or arduino) via serial or usb connections, since 1976.http://www.x10.com/automation/sr227_s.html

For all you anti-multi-voltage in the same box yahoos check this out-
This is a UL listed product.
This handy little cube has a total of six wires sticking out of it.
A 120V Hot
A 120V Neutral
A 120V Switch Leg
3 LOW VOLTAGE switch wires
It’s about 1 Inch Cubed
Slam it into a box, or a fixture connect your low voltage t-stat wire that is rated for 300V in the same enclosure and….
BAM!
You have a great little switch system that turns on a light when you open the door or whatever you want it to do really.
You get… If memory serves me correctly 6 Amps of rated contacts. There is no saftey there is no fuse, you only get breaker protection from burning this bad boy out.
Go take your opto-isolators to your pretty PLCs.
Yes opto-isolators have their purpose. You NEED them in certain situations. Usually High Voltage and/or High Current Situations.
And please, don’t even try to argue that 120V 15A is High Voltage and/or High Current.
If I could not mix voltages in the same box as a resi electrician I could not do my job. Yes there are restrictions but opto-isolators are not a necessary requirement of those restrictions.

Your device is UL listed. His was not. It’s not in the wall, so it’s not a big deal. I know you can mix voltages. I replace more burnt out 120v equipment than I do 480v. 120 gear likes to catch fire. 480 usually goes quick and pulls the breaker with it. I merely suggested the opti as a good practice. Do what you want.

It’s rated for less then full circuit current just like a lot of equipment you wire in a house.
Look at most dimmers- they are not rated for a full circuit load, most are rated for only 600W – if you don’t gang them and break their tabs. There is no fuse on them, they just burn out.
I wire them that way because that is the way the code and their instructions tell me to wire them.

from a security standpoint, opto-isolators certainly are a benefit, but they are only required by law (i.e.: “prior art”, “state of the art” clauses), if the relay used is /not itself/ rated for use in such a “class II isolative” protected application.

There are some industry standards (e.g. EN 60335-1, (IEC 60990: 1999) Deutsche Fassung EN 60990: 1999 or DIN VDE 0106), but basically what you want is an isolation that is as effective as an 8 mm creepway on any surface, or 6 kV voltage.

Another good indicator is: can a single, flattened drop of water cause dangeraus loss of insulation?

Other issues are contact current, electromagnetic interference and switching/breaking capacity.

The EMI is adressed with opto-isolating and snubber circuits, for higher currents you need bigger relays, and for higher switching power and breaking capacity you choose a contactor.

If the contact current is rated smaller than the wall outlet rating and a short-circuit or overload can not completely be ruled out, you need an extra fuse.

I just stumbled upon this old thread and realised, “protective isolation” is a rather unfortunate term for what I meant here.

The correct term for electrical insulation as a means of providing safety even in case of single faults would be “reinforced insulation” instead of “protective isolation”, which seems to denote putting some person in an isolation room for medical reasons..

That at least is in accordance with most international safety regulations like IEC 60664.

If you forgot about building it into the outlet and just made a box that plugs in over the outlet then you do not have to worry about building codes.

If you do this hack and your house burns down, even if it was not the hack that started it, the insurance company will have a good excuse to back out of covering the loss. I would advise that you NEVER do something like this unless it is 100% in line with your building codes.

@SeanL: You see that cord coming out the left side of the box in the first picture? That’s the cord that plugs into the outlet, which means that this already does exactly what you say it doesn’t, except it’s in one of the CHEAPEST project enclosures I’ve ever seen (70 cents)

I’m trying to sense 110v bath fan turning on and subsequently closing a 24v circuit for a heat recovery ventilator controller. I’m stumped by what I see as NEC limitations. Any ideas? I think a 120v coil relay n/o with spdt output side would work, but mixing 600v insulation romex and thermostsat cable in the same box seems to be a no no. Thanks/Don

Totally cold device! I was wondering if there’s something like this readily available on the market. I want to connect a water sensor to a shop vac to collect winter vehical drippings up off my heated garage floor. Any insight would be awesome!