Picture of Connecting a 12V relay to Arduino
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 adsRemove these ads by Signing Up

Step 1: Measure the coil resistance

Picture of 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.
1-40 of 48Next »
amajhi made it!19 days ago
I made the circuit with 6v relay which I really needed. The instructions were really easy to follow.

I controlled a white led and a yellow led with the relay. The red led shows the status of digital pin.

It was fun to make!
Thank you!
mabedin11 month ago

The Ground from 12 Volt that is used to drive your Motor or other device is shared by the Arduino Ground and the Negative - 12Volt, this way Pin 13 is isolated & receives no +12 Volts which would obviously damage it. The relays trigger Current must be within Transistors power range, if well below milliamp (200Ma) should be OK, but a large one may be no good buy one off Bay is that's the case.

thank you for this info..
but can i use 12v 120vac/10A RELAY? instead of 125vac?

thank you for this info..
but can i use 12v 120vac/10A RELAY? instead of 125vac?

SasonoG2 months ago

5v arduino pin goes to transistor then goes to relay (which is need 12v), then where do relay get its 12v?? correct me if im wrong..

Anuj FALCON2 months ago

Very good

reedict8 months ago

it doest work ... your negative from the battery goes were???

ianni reedict7 months ago

Ground. This is the most simple control of a relay with a uC and it works. Have fun!

SamiulI7 months ago

First of all, I am new at this. So, if you start from the very basic, it would be helpful for me.
I have an 8pin 12v relay [exactly same as the given pic] and i don't have the pin configuration & datasheet. I want to make an water alarm system. Based on the water level I can control an LED without any hassle as arduino serves 5v which is enough for that LED.

Now I want to turn on a 12v speaker instead of the LED. Arduino cannot provide that desired 12v. Someone asked me to buy a relay and N-mosfet and these will do the job. But, i cannot understand a line. Could you please help me to build my circuit? I will be really thankful.

bogd8 months ago

Just one question (and please forgive me if you already mentioned this somewhere else): shouldn't it be R1=(U-Ube)/Ib?

With BC548 having a typical Ube ov around 0.7V, this would make it (5-0.7)/0.0004 = 10.75 KOhm.

Which makes your chosen value (10K) even more accurate :)

feedel11 months ago

I have 4 relays and I want to control it by Arduino form the following:

1 - if first relay work by Button No. 1 even if we pressed on any Switches last three relays will not work

2 - If the first switch off the second is work and it control on the third and fourth

3 - If the first and second switch off , third relay is working after pressing button 3

4 - If the first and the second and the third switch off ,forth relay is works after pressing button 4

5 -If the first switch working another time ,first relay is working and all another relays is off.

please how it work and sketch.

slr1337 made it!1 year ago

Hi. I love your article here it is very informative. I tried to make this and was somewhat successful. I say somewhat because it sorta works. When connected to my arduino uno it pulses like it is supposed to. I know because I checked the continuity between the emitter and the collector. It is clearly only open when the base has voltage to it. The problem I am having is even with no voltage to the base I connect my 12vdc power source (a car battery), and it seemingly ignores the transistor in the circuit and powers the relay coil. The coil does not lose power until the power source is disconnected. I am using the same transistor as you and the same diode. My relay is a 12v/12v and the resistance of the coil is 83 ohms making my resistor a 2.2k (tried a 2.7k it was to high). If you could help me out in understanding this it would be much appreciated.


Hello, I have a similar problem. I've successfully made your circuit using a 2N2222A transistor. I couldn't get the 10k resistor to work with it, so I tried a 1k which didn't work either. I then tried a 330 ohm resistor which seems to work. Only now the transistor pulls in the relay when it should but then latches, keeping the relay on until I remove the 12V supply to the coil completely. Any suggestions?

What are the ohms on the coil of your relay.

homunkoloss (author)  slr13371 year ago


can you post a picture of the relay where one can see the label?



Thank you for getting back to me. I actually had a suggestion from a forum I posted on suggesting that I had the transistor's emitter and collector switched around. This was the case is working good now. Thank you.

Nice Thanks man
KJ4ZVQ2 years ago
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 Carmen2 years ago
Cool ! Now I know how to interpret the relay. I finally understood. very nice, thank you. Del Carmen
renefabri2 years ago
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.
best tutorial ever
thank you so much
i searched the net alot
and that is the best one on the net
thanks alottt :)
salvocanna2 years ago
I made this:
It's almost the same... but the relay is 5V and is a shield.. take a look :)
jashan5102 years ago
my coil resistance is just 71ohm so Ic comes really high
if i put a resistor in series wid d coil would it work?
dcutler19583 years ago
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?
gamingman3 years ago
Major point: Make sure you connect the 12V ground to the Arduino ground, or it will not work.
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!
thecageybee5 years ago
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.

The Cageybee
homunkoloss (author)  thecageybee5 years ago
"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.
Oopps!  'mybad.  Need to read the whole of the post.   Second question answer in step 7.

Appologises!  :-)
 The Cageybee
Decypher46 years ago
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)  Decypher46 years ago
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
SPDT 5v amp realy $5.08 radioshack direct2U order
I guess it also depends on your definition of cheap.

This one is $15.00 US

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.

Happy hunting.

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)  Decypher46 years ago
Ok in here you can get one like mine for ~1€ (= 1,2951$)

greetz Daniel
That's cheaper than 9 bucks. Good instructable.
andrew1015 years ago
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 :)
jtbz765 years ago
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)  jtbz765 years ago
What is the number on your transistor ? Sure that its a transistor not a triac or something ?
1-40 of 48Next »