Need help calculating resistance for transistor base

Let's design for worst case, that is a good practice.

\$Ic = 133\text{mA}\$

\$h_{FE} = 30\$ # according to the datasheet minimum 30, typically much better; @Ic=100mA

You can calculate Ib now:

\$I_b = \dfrac{I_c}{h_{FE}} = \dfrac{133\text{mA}}{30} = 4.43\text{mA}\$

\$V_{BE,SAT} = 0.95\$ # datasheet, nearest match is 50mA. Maximum value, practical value is probably much lower (0.65V)

Now let's calculate the base series resistance. This is equal to the voltage across the resistor, divided by the current through it. The current through the resistor is the same as the base current. The voltage across it is the rail voltage (5V) decreased by the base-to-emitter voltage of the transistor V(CE,sat).

\$R_B = \dfrac{U_{R_b}}{I_b} = \dfrac{V_{CC} - V_{BE}}{I_B} = \dfrac{5 - 0.95}{4.43/1000} = 913\Omega\$

With all the worst case engineering up to here, for once let's just round it up to the nearest E12 resistor value of 1kΩ (or 820Ω for worst case engineering, it will work with either).


You are right in that the relay coil seems to need 133 mA nominal. However, that's not worst case, and that assumes 12 V is applied accross the coil. Nevertheless, that's a good place to start, then we'll throw in a factor of 2 margin later anyway.

Let's say the minimum guaranteed gain of the transistor you will use is 50. That means the base current needs to be at least 133 mA / 50 = 2.7 mA. If your digital output is 5 V, then there will be about 4.3 V accross the base resistor after accounting for the B-E drop of the transistor. 4.3 V / 2.7 mA = 1.6 kΩ. To leave some margin, use about half that. The common value of 820 Ω should be good.

Now check back to see what the digital output must supply. 4.3 V / 820 Ω = 5.2 mA. Many digital outputs can source that, but you need to check that yours can. If it can't, you need a different topology.


Since you are using the transistor in a saturated switching configuration it is OK if you pump more base current into the part than actually required for the amount of collector current that you intend to sink through the device from the relay coil.

That is a practical limit to the maximum base current that you can inject in the case of the 2N3904 / 2N4401. That limit is not always explicitly stated in the data sheets for the parts but I can tell you from experience it is in the 5->6 mA range.

For a switching design you may want to plan for the minimum guaranteed Hfe plus a margin. So lets say you pick 25 as the worst case working Hfe. With a needed collector current of 133mA and a Hfe of 25 will result in a working base current of 5.32mA. This seems to be in the OK area for these transistor types.

It appears that you intend to drive the base from a 5V signal. With a nominal Vbe of 0.7V that leaves you with a 4.3V drop across the base resistor. Resistance to limit current to 5.32mA at 4.3V is approximately 800 ohms. Use an 820 ohm standard value base resistor.

Final note. If you are driving this direct from an MCU output pin the MCU may not be able to source 5.32mA at 5V output level. As such the MCU output will drop down some from 5V. This will reduce the base current some but since we calculated using worst case Hfe the relay drive will still work for most transistors that you will pickup out of the bag.