I already read the post Which resistor for NPN transistor base? But I still cannot understand the base resistor calculation.

I need the transistor to be a switch to 5V 200mA relay. The base will get its power from the AVR, which will give it 5V.

I am using 2N2222, and I understood it is related to the \$ h_{FE} \$ value.

On the datasheet I can find the \$ h_{FE} \$, but it has a lot of values.

_multiple_ hFE values in a datasheet

Do someone have simple tutorial for the calculation ans explanation of the BJT values? I tried to Google a lot of stuff and read a lot of articles, but none of them was simple enough.


You will notice the different hFE values are for different conditions of operation. Ask yourself which of those is closest to the way you want the transistor to work when on. Looks like you want Vce to be very low (less wasted power) at Ic=200mA - so the closest match would be the value for Vce=1V, Ic=150mA which gives hFE>= 50 and therefore Ib=4ma so you COULD use 4ma as the base current for resistor calculation.

In fact it is better to turn on the transistor even harder (lower Vce, less power wasted in the transistor) so I would recommend Ib=10ma or even 20ma. The latter value will "saturate" the transistor (at which point Vce<=0.2V) and saturation is usually considered to occur for Ib=Ic/10 (or equivalently, hFE=10).

There is no point in increasing Ib any further and some CPUs would have trouble driving 20mA or even 10ma from an I/O pin (though an AVR should be OK).

  • \$\begingroup\$ Depending on the rest of the system, the heat sinking of the AVR, and if there is any other high current draw from the AVR I suggest you DO NOT try to drive 20-30mA out of it. Use another form of control, or set up your own transistor interface stage (using two 2n222 with the first driving the base of the second). A MOSFET (high side or low side power switch style) seems like a better option to power the Relay. It can be "hard on" wasting very little power or heat, and the relay can get all that it needs... Relays are not exactly suitable for "current controlled" operation \$\endgroup\$ – KyranF Apr 8 '14 at 23:17
  • \$\begingroup\$ I need the AVR to run 2 relays, so I want the AVR pin to output 5mA each. Cannot I use higher resistor on the base and use 2n2222? \$\endgroup\$ – gabi Apr 9 '14 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.