I have this diagram, now the arduino uno output pin (microcontroller) is 5 volts, what is the value of resistor R1 and R2 ?

I have this diagram, now the arduino uno output pin (microcontroller) is 5 volts, what is the value of resistor R1 and R2 ?

What's the relay coil current? The resistors are determined by this.
I would leave out R1. R2 could be roughly 10*5V/(relay coil current in Amperes), if "U2" is a typical NPN transistor, and capable of easily handling the coil current.
Do not exceed 20 mA current draw from an Arduino I/O pin.
What I typically do is use a logic level avalanche rated N-Channel FET such as a 2N7000 or 2N7002 as the output device. Then I use a resistor (R2) in the 500 Ohm range from the arduino pin to the gate as protection for the Arduino. At that point you do not need any of the diodes or R1. Keeps the layout simple. However if your drawing is indicating a connector as J1 then I would suggest adding a 10K pull down resistor on connector side of the gate circuit to keep it from randomly switching when disconnected, it will simply go off. I am assuming you are using a small relay, if you go larger you simply change to a larger FET. This circuit will switch on when the Arduino is reset until you initialize the output pin. If you have a bunch of these look at a ULN2003.
See: https://www.vishay.com/docs/90160/an1005.pdf
You can do the same thing with the transistor, that should give you a solid 100 ma Out. I use a gain of 10 for this type of circuit, sometimes 20 for a little softer turn on.
gilshultz:
At that point you do not need any of the diodes...
You definately need a diode across the relay coil.
Leo..
This is the relay, I dont know what is the relay coil current ?
Features:
Pins: 5
SPDT Contacts
Specifications:
Rated Load: 10A 250VAC, 10A 30VDC
Max Switching Current: 10A
Max Switching Voltage: 110VDC / 250VAC
Coil power 0.45W
Contact Arrangement: C:1 (NO/NC)
Dimensions: 19 x 15 x 15 mm

Power (Watts) = Volts*Amps, so the 12V relay coil draws about 0.45W/12V = 37 mA.
The kickback diode across the coil terminals is absolutely required.
mikechale:
I dont know what is the relay coil current ?
Google knows.
Enter the number (SRD***) in the browser, followed by "datasheet".
12volt L-type >30mA.
You need 5-10% base current for an average low/medium power transistor for switching.
3mA works out to (5-0.7)/0.030.003= 1433ohm.
The 2k2 you have used in your cross-post works out to 4.3/2200= ~2mA, which is fine.
Leo..
what is 5 ?
what is 0.7 ?
what is 0.03 ?
sorry, the answer is 143 ohms ?
mikechale:
what is 5 ?
what is 0.7 ?
what is 0.03 ?sorry, the answer is 143 ohms ?
5 is volt from the Arduino pin (assuming a 5volt Arduino).
0.7 is the base-emitter junction drop of the transistor (4.3volt left across the resistor).
Sorry, missed typing a zero. Should be 0.003 for 3mA.
The answer (1433) is correct.
Any base resistor value between 1k and 3k3 is ok (you had 2k2).
Any volt drop between 0 and 1volt across the transistor is acceptable.
A 12volt relay doesn't really care if it only gets 11volt.
Leo..
Thanks a lot...
R1 is to ensure the relay operates immediately on power-up while the Arduino is starting up - if its there its presumably needed.
For 37mA load 4mA base current is right for the transistor, so R1 = R2 = 470 ohms will ensure at least 4mA
is available to drive the transistor.
The diodes can be 1N4148, the current is low.
jackrobot:
What happens when the arduino gives logic level 0 to the base of transistor. Base current can be adjusted by R2 only.
Not a problem. The pin is at about zero volts, the transistor turns off. Output drivers have about 40 ohms of resistance so win over R1.