1
\$\begingroup\$

I want to make a plug that I can turn on and off with a micro controller like a raspberry pi.

I picked up one of these http://www.radioshack.com/radioshack-15a-12vdc-125vac-relay/2750031.html
And the device I want to power is within the relays specs.
115 vac, 12 amps

I don't know how to wire it up, and I'm hopeful that someone has worked with these before

\$\endgroup\$
  • \$\begingroup\$ That relay is most likely going to fail after very few operations. Use one that's specifically rated for motor load of 1HP @ 120VAC and check the life (some 30A relays have average life of only 1000 switching operations with 1HP motor load). Also for the operations it does last, your chances of disrupting the Pi operation are non-zero. \$\endgroup\$ – Spehro Pefhany Jul 28 '15 at 12:57
  • \$\begingroup\$ @SpehroPefhany Any suggestions on where to get a relay that will be of better suited for the job? I can probably keep this relay and use it for something with a lower power requirement, but I'm not really sure what to look for in a new relay. \$\endgroup\$ – AndyD273 Jul 28 '15 at 13:12
  • \$\begingroup\$ An ideal type is the Omron G7L series, which you can get from Digikey for about $13. Designed for this task. If switching is very infrequent, a T90 type (originally Potter & Brumfield but now many suppliers and quite cheap) but they're significantly crappier. Both types require much more coil current (100-200mA at 12V) so the below drivers may not be adequate. \$\endgroup\$ – Spehro Pefhany Jul 28 '15 at 13:27
  • \$\begingroup\$ @SpehroPefhany It'll be pretty infrequent. It's for a pool pump, so once a day it'll be switched on, run for 8 hours, and turn off. I could just use a timer, but I want to learn relays and micro controller programming. Since they take so much coil current, could I use the relay I have to switch on the 12V needed to power the bigger relay? Would a SSR need as much power to switch? Also, how does this T90 look: amazon.com/dp/B0087ZDUCU \$\endgroup\$ – AndyD273 Jul 28 '15 at 14:28
  • \$\begingroup\$ Yes, you could do that, and it would give you a bit more isolation. SSRs need little power to switch but introduce more problems (they have to be kept cool, which is often a hassle). The relay you linked to is of the T90 construction but of dubious provenance. This one T90S1D12-12 is cheaper and has real approvals and believable datasheet. 10^3 operations so it should last almost 3 years at 1x per day. \$\endgroup\$ – Spehro Pefhany Jul 28 '15 at 14:43
1
\$\begingroup\$

To say that the motor fits the relay specifications would need more than just the label. If it is fully compensated for its stalled start behaviour with the right start capacitor (that's still in good condition) it might be.

If it isn't compensated or not enough, or even over by a good margin, the relay may not last as long as you like.

Before you use this relay to switch any kind of mains voltage, please make sure it's new and has a clear stamp from a recognised testing institution (such as UL). I think with Radioshack chances should be good enough, but I have no personal experience.
The problem is that the middle pin, between the two pins that go to your Raspberry, is the centre contact of the switch. If the relay is badly made or you are not very careful you are effectively laying a mains wire extremely close to your logic 5V system. If they couple (physically or just through leakage) your entire Raspberry and everything it connects to may become "hot". So be weary and careful when hooking it up and make sure the relay looks good, new and reliable with some form of (international) approval.

That said, as I said the middle pin in the row of three is the middle contact. You can measure which one it makes contact with when the relay is off with a multimeter. Then use a 12V supply to turn on the coil (the outer 2 pins in the row of 3) and verify that the contact now connects with the other pin and no longer with the original one. That gives you your switch pin-out.

Then if you make this (while, again, taking care to insulate, insulate, insulate!):

schematic

simulate this circuit – Schematic created using CircuitLab

As you can see I made the mains phase the one on the switch over contact side, when the relay is off, that adds a teensy bit of extra safety, because the middle contact is not connected to phase any more. Of course only works as a trick if you are always 100% sure which the phase is.

The diode is to protect the transistor from switch-off transients.

The transistor can be any modern NPN type, or even an older BC550. Or you can replace it by a MOSFET like 2N7000 or 2N7002, but the 2N3904 is very well suited for the purpuse of relay switching up to 24V or even 48V (from memory it has 60VDC breakdown)/

\$\endgroup\$
  • \$\begingroup\$ It is a brand new relay, just bought it yesterday. It has a RU UL Recognized Component Mark. \$\endgroup\$ – AndyD273 Jul 28 '15 at 14:01
  • \$\begingroup\$ Ok, so I bought the 2N3904 and 1N4148. So it looks like the 2N3904 kind of acts like a relay too, lets me switch on 12V since I cant push that out of the board. I couldn't find a 5K resistor. The closest I could find was 4.7K Not sure if that'll make a difference... \$\endgroup\$ – AndyD273 Aug 4 '15 at 12:29
  • \$\begingroup\$ @AndyD273 I should have said in the answer that 510 Ohm ~ 5k will probably work. A bit lower is not a problem since the transistor will be forced deeper into saturation with a higher base current. And resistors aren't that accurate anyway. A bipolar transistor (like the 2N3904) works as a current amplifier that can handle a certain maximum voltage when turned off, in this case 60VDC. If you put X mA in the base, the collector wants to pull X times Y mA through your relay, where Y depends on the transistor, voltages and exact currents. The resistor limits the base current to avoid damage. \$\endgroup\$ – Asmyldof Aug 4 '15 at 14:05
  • \$\begingroup\$ So after much delay I got this DPDT relay which is rated for 1HP. Am I right in reading that circuit diagram that the diode is mounted backward to the current? And if I have a 12V power supply for the coil, can I get away with only running a single wire from my GPIO, and not a separate ground? \$\endgroup\$ – AndyD273 Jan 24 '17 at 18:03
1
\$\begingroup\$

There are two aspects to this:

(1) You need a circuit to drive the coil of the relay. The easiest way to do this is to use a BJT transistor to control the current through the relay coil. The 3k3 resistor (3300 Ohm) is to limit the current from the microprocessor's output pin into the base of the transistor. The voltage (+V) driving the coil can be much higher than the supply to the microprocessor. Typical coil voltages for power-switching relays are 12 or 24VDC. It looks like you have a 12V relay, so you need to have +V = 12V.

The 1N4004 diode is required to protect the transistor from flyback voltages when you turn off the relay. If you leave out the diode, your transistor will be hit with extremely high voltages (could be 100's of volts if it's a fast-acting transistor) and it will be destroyed in a puff of smoke.

I've suggested a 2N2222A transistor. Make sure it can handle the current that will flow through the relay coil.

(2) As you've bought the relay at Radio Shack, I'll assume you are in the USA. At a minimum, you will need to use the relay to cut or connect the "line" wire (L) (the narrower slot on a polarized plug). In a properly-wired home, the line wire carries 115VAC and the "neutral" wire (N) is near-ground. Given that you cannot guarantee that a home is properly wired (L and N could be reversed), and it is unwise to leave the "hot" wire connected to a load, it is best to use a double-pole relay to open/close BOTH the line and neutral wires. For European users, you will definitely want to cut both wires with a DP relay as there are both "Y" and "delta" phase configurations used in different countries, and both wires may be "hot".

Your relay is a single-pole relay, so it's not ideal for this application (unless you trust the wiring it will be use with).

Finally, I would recommend using the normally-open contacts of the relay. This means that your circuit must actively close the circuit (energize the relay). If something goes wrong with your control circuit, it is most likely to stop driving the transistor and hence cut power to the relay and load. It's safer this way.

Don't forget to wire together all the grounds for safety!

enter image description here

\$\endgroup\$
  • \$\begingroup\$ I'm in the US, and I'm pretty confident that the house is wired correctly, but I want to do it right. Do you have a recommendation for a DP relay that would be able to handle a large power draw? The motor will be running for 8 hours at a time, and I know it pulls a lot of juice. I'd rather over engineer than just squeek by and damage the motor, pi, or people. \$\endgroup\$ – AndyD273 Jul 28 '15 at 14:01
  • \$\begingroup\$ I took a few minutes at digikey.com and found either the T92P7D52-12 or T92P7D52-24 (they differ only in coil voltage). Rated for 1HP @ 120VAC, 100k operations. These are DPST (double-pole, single-throw*) relays with normally-open (NO) contacts. (* For interest, a double-throw relay simply has two sets of contacts - one set connected when not energized, and the other set connected when energized). \$\endgroup\$ – EBlake Jul 29 '15 at 6:38
1
\$\begingroup\$

This answer is slightly OT, but explains why you need to have a relay rated for the load.

A simple relay can cut power to an AC motor very easily because the current flowing to the motor drops to zero 100 or 120 times per second (depending on whether you have 50Hz or 60Hz power). That means that the inductive spark that forms across the relay contacts as they open will extinguish itself after at most 16-20ms. Not enough time to overheat, melt, and weld (!!!) the relay contacts, if they are rated for that sized load. If you look closely at a relay (if it has a transparent case) you will see these sparks when the relay opens (if disconnecting an inductive load, like a motor). Maybe you will even smell the ozone. The relay rating relates to whether the contacts can carry the required operating current (inrush, stall, etc.) and whether they can withstand the inductive spark.

For readers interested in connecting or disconnecting a DC motor, you will have to do a little more work...

If you disconnect a DC motor using an AC-rated relay, that arc will NOT extinguish and you will fry the relay after very few cycles (maybe just one operation). You must use a special DC-rated relay that uses much larger contact separation, operates submerged in oil, or uses some sort of spark suppression or snubber circuit to extinguish that arc before it melts the relay contacts.

\$\endgroup\$
  • \$\begingroup\$ Does it matter any that this relay is rated for AC and DC? \$\endgroup\$ – AndyD273 Jul 29 '15 at 13:45
  • \$\begingroup\$ @AndyD273 A late answer... Relays are often rated for AC and DC, but the DC ratings are usually significantly lower. It's always a good idea to check the datasheet. \$\endgroup\$ – EBlake Jan 3 '17 at 4:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.