Step 2: Calculate how much current will flow

The formula you need is a simple one:

(maybe people in England or the US know the Voltage as "V" but I will refer to it as "U" as we call it in here)

U = R * I

OK, but we want the current "I" right ? So just divide through the Resistance "R".

U = R * I / :R

I = U/R

For my relay that would be:

I = 12V / 400Ohm
I = 0.03 A => 30 mA (That is Ic)

The Arduino can handle up to 20mA but its better to use a transistor even if your current is only 20mA. So for 30mA you definitely need one.

<p>Hi i make a video how to connect and use relay module with arduino uno.</p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/S-QddCWt5l4" width="500"></iframe></p><p>codes and diagram is in link of video</p>
<p>The most commonly used <a href="http://www.dnatechindia.com/Cube-Relay.html" rel="nofollow">12 Volt cube relay</a> has 400ohm coil resistance. So the current required is 12V/400 = 30ma . But this is the holding current the pull in current is a bit larger than that so you normally design with assumption that current required atleast 1.5 times of calculated current.</p><p>You should use 1N4148 diode instead of 1N4007 as 4148 is a fast switching diode with maximum forward current of 300ma. </p><p>If you have relays with lesser coil resistance so the current required for relay is more then you can add a pull up resistor to the arduino pin. A pull up resistor is basically a resistor between the controller pin and the Vcc. If you use pullup resistor you can use the above <a href="http://www.dnatechindia.com/Interfacing-Relay-to-Microcontroller.html" rel="nofollow">relay driver circuit for interfacing with any microcontroller</a></p>
<p>I have 5V relay with 70 OHM coil resistance,and i'm using 2N2222A transistor and it doesn't work with Arduino ???!!!!! any help please???</p>
<p>Can some1 post diagram on how to use the relay with arduino with 12V 1A power supply to Arduino and no different power source for the relay.</p><p>Also note the protection diode is needed.<br>I have made the relay work but not with the protection diode.<br>And engineers, please, in the diagram please display from with pin to which pin the diode is used for newbies like me.</p><p>Thank you.</p>
<p>Built it today, and it worked just as the author said it would. Only difference was that I substituted a different diode (1N4001) instead of the one suggested.</p><p>Thanks for the build!</p>
<p>Ok can someone tell me why da hell do we need a transistor or a mosfet if your using a relay? the both work the same way only that one is for Ac power &quot;relay&quot; and the other is for Dc power &quot;transistor/mosfet&quot; GATE/ latch on the transistor just needs 5v to trigger it and the same can be said about the relay it needs 5v to trigger the gate /SIGNAL to open/close the circuit so whats the point? BUT even a some relay's can be used with Batteries for DC 12-30V @ 10-30A not just AC so again why use a transistor? i can see why the diode or even a resistor but a NPN or PNP com'on someone break it down just as i have.</p>
<p>As the author stated: he use a normal 12v relay (maybe the only one he had at hand)</p><p>and it take 30mA from 12v control source.</p><p>If you apply 5v directly to the coil of 12v relay using IO pin of arduino maybe the current is not enough to switch the latch since 5v / 400 ohm = 0.0125 A or ~13mA compare to typical 30mA of 12v relay. So you have to use a transistor as a switch so that you can use 5v source of arduino to switch on 12v source to power the relay. Any 12v source would be fine if it is able to provide current larger than 30mA.</p><p>If you use 5v relay and use arduino IO pin to drive the relay directly, the coil resistor is around 70 ohm which needs ~71mA to work. This time 71mA excess the absolute 40mA current limit of arduino IO pin. It will likely damage your arduino. So again, you have to use transistor as a switch to amplify the current apply to the relay coil.</p><p>These are typical relay you will find on ebay.<br><br>Yes, when using a single mosfet or transistor, you need less components but it is more complicate with calculation and less flexible in general applications. Say, you wish to turn on a small LED stripe or a garrage door motor, the easiest way is using a relay.</p><p>Sorry for my bad english</p>
ok so i just have to use a transistor or in my case a mosfet since im playing with DC motors who are higher then spec of both the MCU &amp; Relay? and the mosfet i choose will have to have a output current of more then 71mOhms ? so that the current of the mosfet can pass thru the coil and make it to the gate of the triggering pin which activates the relay function ? on the relay it self?
ok i can take that i do see your logic, thanks for that @1413<br><br>tho now hear my point of view'<br><br>you said:<br>5v / i40mA = 0.0125 ohms or ~13 ohms compare to typical 30mA of 12v relay.<br><br>So if arduino has 40mA and the relay needs 30mA doing your math i see no reason for the over kill, the arduino looks like supplying 40mA of which the relay only needs 30mA as you said, so what is it im not understanding? theirs a extra 10mA of a overkill so if anything a resistor should be used to not fry the relay from excess mA's <br><br>on your 2nd statement your saying the coil of the relay is 70 ohms<br>so RxI=V (70 ohms x 30 mA = 2100) <br>whats going on?
<p>ah I see, you misunderstood some concept.</p><p>Ohm laws: R*I = V or I = V / R.</p><p>and we work with Ampere and Volt and Ohm, if it is mA or mV or kOhm, you have to convert it to standard unit to work with the equation.</p><p>First, the recommended current of each IO pin of arduino is 20mA. The absolute Maximum Ratings - the point where damage will start to happen: DC Current per I/O Pin ........... 40.0 mA</p><p><a href="http://playground.arduino.cc/Main/ArduinoPinCurren..." rel="nofollow">http://playground.arduino.cc/Main/ArduinoPinCurren...</a></p><p>So anything that draw more than 20mA on a single IO pin is not recommended for a long time.</p><p>Second, you misunderstood my equation:</p><p>400 ohm is the resistor of the coil of the 12v-relay.</p><p>- If you apply 12v on the coil the, equation is:</p><p>I = V / R = 12 / 400 = 0.03 Ampere (30 mili Ampere)</p><p>This 30mA is the normal working condition of the relay under 12v control source</p><p>- But if you apply 5v on the coil, the equation would be:</p><p>I = V / R = 5 / 400 = 0.0125 Ampere (~13mili Ampere)</p><p>This maybe not enough to switch the latch.</p><p>And your equation : 5v / i40mA = 0.0125 ohms is not correct.</p><p>The correct equation is </p><p>R = V / I = 5v / 40mA = 5v / 0.04 A = 125 Ohm.</p><p>This means, if you can find a relay with the coil resistor is about 125 Ohm. It might work.</p><p>And this one is wrong too: RxI=V (70 ohms x 30 mA = 2100) </p><p>It should be 70 ohm x 30mA = 2100mV = 2.1v</p><p>It means if you have a 70 ohm coil, you want a current of 30mA goes through it, you will need to apply a voltage of 2.1v</p><p>OK. For a eqation like I*R = V , you should find which variable is the constant and which is not or what is known and what is not known so that you find the unknown.</p><p>Resistor, voltage = constant. You likely can't change them but you CAN mesure them using volt-ohm-meter BEFORE connect the coil to arduino. That leave Current is unknown. You haven't connect them so you can't mesure the actual current flow through the coil. And 30mA we are talking about is the ideal value for the coil to work, not the real current flow through the coil in real circuit.<br><br>Hope this will clear your mind.</p>
<p>Why do you show a 9V battery source when 12V is specified?</p><p>The specs for Duemilanove say pins can provide 40mA, not 20mA. If the relay coil was 5V 30mA you could power it with the 5V pin correct?</p><p>I don't understand transistors very well. A base current of .4mA with 75hfe will allow 30mA to pass from the 12V source and switch the relay, correct?</p>
Kindly tell me how much oms resistance do we have to use to connect ardino and circuit please tell me as you connected please tell me as soon as possible
I made the circuit with 6v relay which I really needed. The instructions were really easy to follow. <br><br>I controlled a white led and a yellow led with the relay. The red led shows the status of digital pin.<br><br>It was fun to make!<br>Thank you!
<p>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 &amp; 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. </p>
<p>thank you for this info.. <br>but can i use 12v 120vac/10A RELAY? instead of 125vac?</p>
<p>thank you for this info.. <br>but can i use 12v 120vac/10A RELAY? instead of 125vac?</p>
<p>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.. </p>
<p>Very good</p>
<p>it doest work ... your negative from the battery goes were???</p>
<p>Ground. This is the most simple control of a relay with a uC and it works. Have fun!</p>
<p>First of all, I am new at this. So, if you start from the very basic, it would be helpful for me.<br>I have an 8pin 12v relay [exactly same as the given pic] and i don't have the pin configuration &amp; 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.<br><br>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.</p>
<p>Just one question (and please forgive me if you already mentioned this somewhere else): shouldn't it be R1=(U-Ube)/Ib? </p><p>With BC548 having a typical Ube ov around 0.7V, this would make it (5-0.7)/0.0004 = 10.75 KOhm.</p><p>Which makes your chosen value (10K) even more accurate :)</p>
<p>I have 4 relays and I want to control it by Arduino form the following:</p><p>1 - if first relay work by Button No. 1 even if we pressed on any Switches last three relays will not work </p><p>2 - If the first switch off the second is work and it control on the third and fourth </p><p>3 - If the first and second switch off , third relay is working after pressing button 3</p><p>4 - If the first and the second and the third switch off ,forth relay is works after pressing button 4 </p><p>5 -If the first switch working another time ,first relay is working and all another relays is off. </p><p>please how it work and sketch.</p>
<p>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.</p>
<p>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?</p>
<p>What are the ohms on the coil of your relay.</p>
<p>Hey,</p><p>can you post a picture of the relay where one can see the label? </p><p>Regards,</p><p>Daniel</p>
<p>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.</p>
Nice Thanks man
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)!
Cool ! Now I know how to interpret the relay. I finally understood. very nice, thank you. Del Carmen
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? <br>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 <br>thank you so much <br>i searched the net alot <br>and that is the best one on the net <br>thanks alottt :)
I made this: <a href="http://blog.salvocannamela.it/scheda-rele/" rel="nofollow">http://blog.salvocannamela.it/scheda-rele/</a><br> It's almost the same... but the relay is 5V and is a shield.. take a look :)
my coil resistance is just 71ohm so Ic comes really high <br>if i put a resistor in series wid d coil would it work?
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?
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!
Hi there.&nbsp;&nbsp; Brilliant post.&nbsp;&nbsp; Very informative, the formulas you have provided have been very helpful, as without them I'd of just been blindly putting components together.&nbsp; Likely with disastrous results.<br /> <br /> I've got a couple of questions for you though.<br /> <br /> First the easy one.&nbsp; Could you explain the formula in step 5.&nbsp; What is &quot;U_L&quot;, &quot;L&quot;, &quot;delta i&quot; and &quot;delta t&quot;?&nbsp; Where do I find their values in regards to the components I'm going to use.&nbsp; 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.<br /> <br /> 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.&nbsp; Can I simulate the arduino by applying a 5v positive to where the arduino would go, with the negative to ground in the circuit?<br /> <br /> Again, many thanks for this guide, and thanks for any help you can give me.<br /> <br /> Regards,<br /> The Cageybee<br />
&quot;U_L&quot; (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. &quot;L&quot; is the inductance of your relays coil. &quot;delta I&quot; is the change of the current and &quot;delta t&quot; 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.<br />
Oopps!&nbsp; 'mybad.&nbsp; Need to read the whole of the post.&nbsp;&nbsp; Second question answer in step 7.<br /> <br /> Appologises!&nbsp; :-)<br /> &nbsp;The Cageybee<br />
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?
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.<br/><br/>This one is $15.00 US<br/><br/><a rel="nofollow" href="http://www.allelectronics.com/make-a-store/item/SSRLY-42/40-AMP-SOLID-STATE-RELAY/1.html">http://www.allelectronics.com/make-a-store/item/SSRLY-42/40-AMP-SOLID-STATE-RELAY/1.html</a><br/><br/>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. <br/><br/><a rel="nofollow" href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Cat=1048664&keywords=solid%20state%20relay">http://search.digikey.com/scripts/DkSearch/dksus.dll?Cat=1048664&amp;keywords=solid%20state%20relay</a><br/><br/>Happy hunting.<br/><br/>Cheers<br/>

About This Instructable




More by homunkoloss:Connecting a 12V relay to ArduinoHow to make your GNOME Desktop even cooler
Add instructable to: