# Connecting a 12V relay to Arduino

8 Steps
To connect a 12V relay to the Arduino you need the following things:

- 1 Arduino

- 1 diode for example 1N4007

- 1 NPN transistor for example 2N2222 (in the US) or BC548 (in Europe)

- 1 relay for example one with coil voltage 12V and switching voltage 125VAC/10 A

- 1 multimeter
Remove these ads by Signing Up

## Step 1: Measure the coil resistance

We are going to measure the coil resistance to calculate the current.

First we must find the coil:
On some relays the pins are labeled so you can just measure at pin 2 & 5.

Otherwise you have to measure at every pin:

Between two pins you should have between 100 and 10 000 Ohm. Remember that value. That are the two terminals of the coil. The coil is not polarized so its not important which one goes to V+ or GND.

If you have found those there are only three left. Between two should be a connection (if you measure a few Ohm its okay but everything above 50Ohm is too much). One of them is NC and one is COM. To find out which is which let one probe connected and connect the other to the pin that’s left over. If you connect the coil to 12V DC it should make a clicking noise. If your multimeter now shows a low resistance you have found COM and NO. The one probe you didn't move is COM the other is NO.
KJ4ZVQ says: Feb 8, 2013. 3:57 PM
Nice! I had one in the making. Good point of showing the power formula to keep from burning up your board(that makes for a VERY bad day)!
Del Carmen says: Feb 4, 2013. 8:16 PM
Cool ! Now I know how to interpret the relay. I finally understood. very nice, thank you. Del Carmen
renefabri says: Nov 27, 2012. 11:34 PM
1. The photo does not show where are connected the green wires at the top, and the yellow wires at the bottom. Am I right to guess at the top (green) is a circuit with a lot of voltages and current (maybe 5V to 220V and 1A to 10A), and at the bottom (yellow) is a 4.5V battery?
2. The R1 resitor, is it what is called a pull-up resistor? I am puzzled because I don't see any connection to the 5V of the Arduino.
palestinian-warrior says: Sep 14, 2012. 1:57 PM
best tutorial ever
thank you so much
i searched the net alot
and that is the best one on the net
thanks alottt :)
salvocanna says: Jun 8, 2012. 10:10 AM
It's almost the same... but the relay is 5V and is a shield.. take a look :)
jashan510 says: May 2, 2012. 11:47 AM
my coil resistance is just 71ohm so Ic comes really high
if i put a resistor in series wid d coil would it work?
dcutler1958 says: Feb 28, 2012. 11:29 AM
I'm a bit lost on the step of choosing a diode. How do you pick a diode knowing the current that passes across the relay coil?
gamingman says: Nov 6, 2011. 8:20 PM
Major point: Make sure you connect the 12V ground to the Arduino ground, or it will not work.
gabriel.hahmann says: Feb 23, 2011. 8:20 PM
I'm using a 5v relay and It is not working. By mistake I bought a 2N2222A, wich I saw on the datasheet had a Vebo of 6V, could you tell me if these is the problem? Congratulations for the great howto!
thecageybee says: Nov 25, 2009. 10:56 AM
Hi there.   Brilliant post.   Very informative, the formulas you have provided have been very helpful, as without them I'd of just been blindly putting components together.  Likely with disastrous results.

I've got a couple of questions for you though.

First the easy one.  Could you explain the formula in step 5.  What is "U_L", "L", "delta i" and "delta t"?  Where do I find their values in regards to the components I'm going to use.  Just not sure if it matters what rating diode I use, or if it's merely mathematical proof that I will need a diode and any diode will do.

Lastly, I'm going to be applying this for a project of my own, but want to make sure I can get the relay circuit working before I get an Arduino.  Can I simulate the arduino by applying a 5v positive to where the arduino would go, with the negative to ground in the circuit?

Again, many thanks for this guide, and thanks for any help you can give me.

Regards,
The Cageybee
homunkoloss (author) in reply to thecageybeeNov 25, 2009. 2:24 PM
"U_L" (L is meant to be the index) is the voltage at the relays coil, Im writing U instead of V because thats how I learned it and how its written in europe. "L" is the inductance of your relays coil. "delta I" is the change of the current and "delta t" is how fast you apply the Voltage (Sorry cant explain this better). The problem is that the Voltage rises very high (probably about 100 to 300 V, but not harmfull because of the low current), this could destroy the transistor. So when choosing your diode you should use one that can stand high voltages.
thecageybee in reply to thecageybeeNov 25, 2009. 12:37 PM

Appologises!  :-)
The Cageybee
Decypher4 says: Jan 19, 2009. 7:44 AM
Why are you using a 12V excitation relay with the Arduino? 5V excitation SSRs that can handle a 120V 40A AC load are cheap and readily available. Did you just have a 12V relay laying around?
homunkoloss (author) in reply to Decypher4Jan 19, 2009. 12:29 PM
Yes it was the only I had @home, its from an old washing machine. Where do you get cheap 5V SSRs ? In here the are expensive. greetz Daniel
Doom2099 in reply to homunkolossSep 9, 2009. 1:56 AM
SPDT 5v amp realy \$5.08 radioshack direct2U order
Decypher4 in reply to homunkolossJan 19, 2009. 3:14 PM
I guess it also depends on your definition of cheap.

This one is \$15.00 US

http://www.allelectronics.com/make-a-store/item/SSRLY-42/40-AMP-SOLID-STATE-RELAY/1.html

There are a bunch here too. There's a million different options to sort through, and I've seen them as cheap as \$9.00 US.

http://search.digikey.com/scripts/DkSearch/dksus.dll?Cat=1048664&keywords=solid%20state%20relay

Happy hunting.

Cheers
andrew101 in reply to Decypher4Aug 15, 2009. 5:17 PM
well i can get a 12 volt relay with 2 seperate switches for 4 \$ canadian at my local ripoff store. i suppose i could get them cheaper online but its eaiser to buy them there.
homunkoloss (author) in reply to Decypher4Jan 20, 2009. 6:18 AM
Ok in here you can get one like mine for ~1€ (= 1,2951\$)

greetz Daniel
Decypher4 in reply to homunkolossJan 21, 2009. 7:25 AM
That's cheaper than 9 bucks. Good instructable.
andrew101 says: Aug 15, 2009. 5:15 PM
cool. i made oneawhile ago that i can trigger thru serial to turn on and off some relays. i didn't realise i should add a diode. good tip :)
jtbz76 says: Jun 29, 2009. 10:40 AM
I made this circuit and when the 5v signal from arduino is off the the relay stays on until the 12 volts is disconnected. Its like the transistor is staying on. Any hints??
homunkoloss (author) in reply to jtbz76Jun 29, 2009. 11:09 AM
What is the number on your transistor ? Sure that its a transistor not a triac or something ?
jtbz76 in reply to homunkolossJun 29, 2009. 9:24 PM
Nope i didnt pay attention that the diagram said view from bottom so i had the emitter and collector reversed. works great thanks!!!
inane says: Feb 17, 2009. 2:23 PM
Can I do without the transistor? I have a reed relay that claims a nominal current of 20mA...shouldnt the Arduino be able to drive it directly?
homunkoloss (author) in reply to inaneFeb 21, 2009. 2:23 PM
If it really only needs 20mA it should be ok with Arduino, but it is better for the Controller if you use a transistor.
russ_hensel says: Jan 20, 2009. 5:31 PM
Microwave ovens ( the control panel ) usually have this type of relay ( more or less ) sometimes 3 of them. Coil voltage typically 12 or 24 volts. Voltage need not be very exact or regulated. Cost normally 0, priceless if you manage to kill yourself on the high voltage.
RCURV says: Jan 19, 2009. 2:02 PM
super useful, I'm planning a sub project an this is just the thing
joejoerowley says: Jan 18, 2009. 4:57 PM
Great! I was just looking for something like this! Thanks, Joe
Bongmaster says: Jan 18, 2009. 12:07 PM
usefull :)
homunkoloss (author) in reply to BongmasterJan 18, 2009. 1:15 PM
Thanks :-)