Relays and Arduino?

I want my Arduino to be able to turn on a 120v AC fan. Basically I had the hopes of making the Arduino turn on a relay which activated a 3 prong house outlet. What kind of relay should I be looking for? Any tips in the right direction would be incredibly useful. I went to an electronics shop today and I was dumbfounded at how many choices there were.

I like to buy through sparkfun, but you should be able to find most of this stuff from your preferred distributor.

  1. Arduino digital outputs can only source/sink ~20mA, enough to drive an LED. For larger loads such as relays and motors, you’ll want a MOSFET.

  2. Now for the relay. This one should work.

  3. There is something called “inductive kickback,” a property of inductors, motors, relays, basically anything that has wire coiled around a magnet, which can create NASTY voltage spikes of ~1kV (1000V) which will fry your arduino and mosfet. Get a diode or two.

So here’s your final setup: [attached]

Remember: DON’T FORGET THE DIODE!

Screen shot 2011-03-11 at 10.32.21 PM.png

STOP!!!

Diode should be flipped!!! Very sorry.

You might be interested in a slightly more finished approach (although a little more expensive.)

http://www.adafruit.com/index.php?main_page=product_info&cPath=44&products_id=268

This approach had the advantage of not having to splice into 120Vac wiring.

Fleshing out the discussion some ... Could probably fit this all in an electrical junction box

James is right... You can choose between $$$ and safety or $ and less safety. Though if you want to make your own :), take some precautions: 1. Wear rubber gloves of some sort as to minimize the electrocution risk. 2. While working, obviously keep the plug unplugged. 3. Minimize the number of bare wires. If 120VAC and GND touch, you're going to have a problem.

Good Luck! Stay safe!

If you don't use the expensive powerswitch tail (which is nothing more than a relay in a box) then you should consider a solid state relay. http://en.wikipedia.org/wiki/Solid_state_relay

Don

Why use a SSR over an EM relay?

Why use a SSR over an EM relay?

There's just four wires to deal with. Two go to the Arduino and two go in series with the AC load. Keep the two pairs separate and you and the Arduino will have a long happy life.

Don

Isn't it the same for an EM relay? Two for coil and two for switch?

What about the diode, the driver transistor, it's base resistor ...? None of those are required with the solid state relay.

Don

You have a good point. wh33t can get something from digikey. Sparkfun, littlebird, etc, only carry 600mA max models.

floresta: What about the diode, the driver transistor, it's base resistor ...? None of those are required with the solid state relay.

Don

You might want a varistor across the output leads, depending on what the load being switched is. Plus, you might need a heatsink with the SSR (depending on the current draw of the load). The only other thing I can think of with an EM relay is that you could (using a DPST/DPDT relay) is switch both neutral and hot at the same time, so when the relay is off, the load is completely isolated from the mains (except for ground, of course). Though as long as you switch the hot lead with the SSR, it should be ok...

I always recommend checking out the information @ Omron, for SSRs:

http://www.ia.omron.com/support/faq/4/31.html http://www.ia.omron.com/support/guide/31/overview.html

They also have some good info on GP relays; just keep in mind it's from an industrial automation perspective, but it still translates...

:)

Plus, you might need a heatsink with the SSR

I have been using some 240V/10A solid state relays to control my 1500W baseboard heaters using just the metal cover of the box they are mounted in as a heat sink. I bought them used, at a hamfest, in the mid '80s so they are approaching 30 years of use by me plus who know how much before.

Don

I might not be very experienced, but I think there is a much better approach - get a Solid State Relay

There are lots of relays that can switch insanely high currents, but there are also lots in 110/240V at 1-4A range

Here are some SSRs that should work well for a fan.

http://www.mpja.com/prodinfo.asp?number=18194+RL 3A, up to 480VAC, $5.95 http://www.mpja.com/prodinfo.asp?number=17844+RL dual 6A, 240VAC, $5.95 http://www.mpja.com/prodinfo.asp?number=17154+RL 10A, up to 480VAC, $7.95 http://www.mpja.com/prodinfo.asp?number=18703+RL 20A, up to 480VAC, $9.95

Since the smaller ones can't handle the 15A that a typical house wall socket is good for, would probably be good idea to have an inline resettable breaker as well to protect the SSR, such as this 10A breaker, and find similar for the 3A & 6A parts above. http://www.mpja.com/prodinfo.asp?number=18100+FU

kerimil: I might not be very experienced, but I think there is a much better approach - get a Solid State Relay

There are lots of relays that can switch insanely high currents, but there are also lots in 110/240V at 1-4A range

Isn't that what all the replies since #6 are about?

Don

lol FAIL uhmm sorry, but I've seen way too many threads suggesting 'get a Darlington driver and use it to power a 5V relay, that in turn powers an AC relay, and so on etc. so somehow I missed that :)

Anyway... I am not very experienced so I'd like to know if there are any disadvantages of SSRs (apart from price and overheating) ?

Did you read the wikipedia link posted earler?

Advantages over mechanical relays
Most of the relative advantages of solid state and electromechanical relays are common to all solid-state as against electromechanical devices.

SSRs are faster than electromechanical relays; their switching time is dependent on the time needed to power the LED on and off, of the order of microseconds to milliseconds
Lower (if any) minimum output current (latching current) required
Increased lifetime, particularly if activated many times, as there are no moving parts to wear
Output resistance remains constant regardless of amount of use
Clean, bounceless operation
Decreased electrical noise when switching
No sparking, allowing use in explosive environments where it is critical that no spark is generated during switching
Totally silent operation
Inherently smaller than a mechanical relay of similar specification (if desired may have the same “casing” form factor for interchangeability).
Much less sensitive to storage and operating environment. For example much less sensitive to mechanical shock and vibration, humidity.

Disadvantages
Voltage/current characteristic of semiconductor rather than mechanical contacts:
When closed, higher resistance (generating heat), and increased electrical noise
When open, lower resistance, and reverse leakage current (typically µA range)
Voltage/current characteristic is not linear (not purely resistive), distorting switched waveforms to some extent. An electromechanical relay has the low
ohmic (linear) resistance of the associated mechanical switch when activated, and the exceedingly high resistance of the air gap and insulating materials
when open.
DC load must observe polarity (- and + not interchangeable) to avoid an undesirable “always conducting” state that does not depend on switching input. Electromechanical relays do not depend on polarity.
Possibility of spurious switching due to voltage transients (due to much faster switching than mechanical relay)
Isolated bias supply required for gate charge circuit
Higher Transient Reverse Recovery time (Trr) due to the presence of Body diode

You win. I'll be looking into an SSR for my next project.