This circuit is for a 5V relay to be attached to an Arduino Nano.
The first version is a recommendation that I found on the internet.
The second version is an actual relay board that I have at home and analyzed the circuit.
Ok, and what about differences in the resistors? I mean 2kOhm and 2.2kOhm is negligible. But, 100kOhm vs. 2.2kOhm ? And what is the 100Ohm resistor doing there?
cipher2k:
Ok, and what about differences in the resistors? I mean 2kOhm and 2.2kOhm is negligible. But, 100kOhm vs. 2.2kOhm ? And what is the 100Ohm resistor doing there?
The difference is in manufacturing! The Chinese factory has rooms full of reels of OLD components. They use what is available, if the circuit works, or in this case, if the relay functions.
One of the secrets to engineering is knowing what's important and what's not. I'd say the diode is important!
It should work fine without R2.
The 100-Ohm resistor is a little weird. There will be a voltage drop across the resistor, but we don't know the coil resistance or current so we don't know how much voltage is "lost". Usually, if you've got 5V and a 5V relay coil, you want all 5V across the coil.
First diagram is not right.
Base current with those base resistor values (and voltage divider) is too low.
That relay might only get 3.5-4volt.
R1 should be <= 1k for proper saturation of that transistor (<0.5volt across).
R2 should be removed.
Second diagram.
My guess is that they needed a 9volt or 12volt relay board, but didn't have 9volt or 12volt relays.
They "fixed" that by using a 5volt relay with series resistor.
The whole setup uses more coil current than needed.
Relay needs a diode across. The transistor won't live long without it.
Base current is the same as above.
Leo..
Thanks for the explanations. But, just to get a better understanding: what could have been the thinking behind adding R2 in the first place if it is not really needed?
I would like to say that you need to use Version 1 instead of version 2. In version 1 there is Diode and it will help to protect your circuitry from reverse flow of current from the magnetic field.
what could have been the thinking behind adding R2
A n channel MOSFET needs the pull down (R2) to keep the MOSFET turned off during a processor reset until the gate pin is set to output. The pin will be a floating input until the pinMode is called to change it to OUTPUT. Maybe the designer thought the same applies to a BJT*. It does not because a BJT is current operated, not voltage. The voltage on a floating input can be anything between 0V and Vcc so the MOSFET could be turned on. The current is virtually 0, never enough to turn on a BJT.
Following on "GroundFungus's comment... its not just for mosfets.
It has been a long term engineering practice to have a high value resistor as a base pin pulldown for anytime the base pin might be floating so it doesn't act like an EMF detector. Its not required.. but its not a bad idea either. A good designer tried to take all possible conditions into account.