Transistor Base Resistor Calculator (NPN Switch Saturation, Drive Current & Power)
Pick the base resistor for an NPN or PNP transistor used as a switch: base current for hard saturation from collector current and minimum hFE with an overdrive factor, the nearest E24 resistor, the current drawn from the microcontroller pin, transistor and resistor power, and when to switch to a MOSFET or Darlington.
How it works
I_B(min) = I_C ÷ hFE(min) · I_B = I_B(min) × overdrive (3–5×) · R_B = (V_drive − V_BE) ÷ I_B → nearest E24 · P_transistor ≈ I_C × V_CE(sat) + I_B × V_BE; P_RB = I_B² × R_B
To use a bipolar transistor as an on/off switch you drive enough base current that the collector cannot supply the load any faster — saturation — so the collector-emitter voltage collapses to a couple of tenths of a volt and the device stays cool. The minimum base current is the load current divided by the transistor's gain, but gain is a loose, temperature-dependent minimum, so designers feed three to five times that. The base resistor is then just the drive voltage minus the base-emitter drop, divided by that current — checked against what a microcontroller pin can actually supply.
Worked example
Switching a 100 mA, 12 V load from a 5 V pin with a transistor whose minimum hFE is 100: the minimum base current is 1 mA, ×4 overdrive is 4 mA, so Rb = (5 − 0.8)/0.004 = 1,050 Ω → 1.1 kΩ (nearest E24), giving 3.8 mA from the pin — fine for a 20 mA pin. The transistor dissipates about 23 mW at Vce(sat) 0.2 V, so a 2N2222 or BC337 in TO-92 is comfortable.
Frequently asked questions
Why not use the exact hFE from the datasheet?
The datasheet gives a minimum at one collector current and 25 °C; real parts vary two or three to one, and gain drops at high current and low temperature. Driving 3–5× the minimum base current guarantees saturation across that spread with only a few milliamps of extra pin current.
BJT or MOSFET for switching a load from a microcontroller?
A small BJT is cheap, robust and fine to a few hundred milliamps. Above about 0.5 A its saturation voltage wastes power and the base current becomes significant, so a logic-level MOSFET (no gate current, milliohm on-resistance) is the better switch. For relays and small motors, a Darlington array like the ULN2003 is convenient.
Can I switch a load on the high side with an NPN?
Not cleanly — an NPN emitter follower on the high side drops the base voltage minus Vbe, so a 5 V drive cannot switch a 12 V load fully. Use a PNP for high-side switching (driven by an NPN if the logic level is below the supply) or a P-channel MOSFET.
Related calculators
Electronics estimates use simplified models and typical component values. Check the datasheet limits (voltage, current, temperature, gate charge, ESR), prototype, and measure — especially for anything connected to mains, batteries or motors.