I'm new to relays and I recently picked up a couple of these:
All I need to know is how to wire this sucker up. I am confused as to where to put my 120AC line and where to put the 5VDC line to trigger the coil.
Ok, so, if the bottom looks like this:
| O O O |
| O O O |
And if you count the pins left to right top to bottom (with six pins #'d 1-6) then 2 and 5 are the pins for the 5V coil. 1 and 3 are the normally closed pins. 4 and 6 are the normally open (and closed when the relay triggers) pins.
Note that the wiring above is for a 842. The 842A is apparently different.
If you're at all unsure about the wiring, do test the relay with just the Arduino (and transistor/diode etc.) wired up and not 120V AC. The relay should make an audible "click" when it operates. If this does not happen, find out why before connecting 120V.
Thanks for the advice. I got the relay working with my transistor.
I just hooked it up to an LED for now and it seems to be working just fine.
Question: I hooked up the relay without a transistor and it worked. Why exactly do I need to use the transistor again ? Please excuse my ignorance.
The maximum rated current capacity of an Arduino pin is only about 40mA. Your relay most likely draws more current than that, so you need a transistor to act as a current amplifier.
Now, your relay may work with the Arduino pin directly, but in doing so you may be exceeding the maximum rated current. It'll work, maybe, but it will start to overheat the Arduino, or maybe it'll fail later, or maybe it will work. Thing is, the manufacturers have told us what they'll guarantee, and the relay exceeds that.
The coil on your relay uses 44.7ma. So it's only barely over the max current capacity of the arduino pins. Still, it is over (and by more than 10%) so it's not a good idea to continue using the relay like that. As anacrocomputer said, a transistor can be used as a current amplifier. A transistor is usually rated way higher than 40ma. 1A transistors are quite common.
Thanks for the info. I no longer have my relay connected directly to the arduino board.
So should I be careful when picking the right transistor ? Will I have to match the transistor to the characteristics of the arduino (40mA draw) ?
Well, yes certainly you don't want a transistor that could draw more than 40ma through it's base. I'm pretty sure no 1A transistor would though. It's still best to look in the spec sheet to be sure.
You will also need a back-EMF diode across the relay coil. It's there to suppress the high voltage "spike" that you get when the relay coil is switched off. Most relay driver schematics that you can find on the 'net will show it.
Will I have to match the transistor to the characteristics of the arduino (40mA draw)
No you will not exceed that because you will put a 1K resistor in the base. This limits the maximum current to 5mA. This means your transistor needs a minimum gain of 45 / 5 = 9. All transistor have a gain of at least that. So anyone will do.
Great thanks for the info again.
I already have a diode in place to protect the transistor.
I'll just throw in a 1K resistor and then I'm set.