Transistor Switch Base Resistor Calculator
Find the base resistor for driving a load such as a relay, motor or LED through an NPN transistor from a microcontroller pin.
Formula and cautions
IB = (k·IC)/(hFE), RB = (Vdrive − VBE)/(IB). A switch should be driven hard into saturation to stay cool, so the base current is the datasheet minimum hFE requirement times an overdrive factor. Always put a flyback diode across coils such as relays and motors.
Worked example: switching 100 mA from a 5 V pin
- Base current: IB = (k·IC)/(hFE) = (5 × 100 mA)/(100) = 5 mA
- Base resistor: RB = (5 V − 0.7 V)/(5 mA) = 860 Ω → next lower standard value 820 Ω
- (IC)/(IB) is about 20 (forced β), so the transistor saturates whatever its actual β.
Base resistor by load current
| Load current IC | RB (3.3 V) | IB (3.3 V) | RB (5 V) | IB (5 V) |
|---|---|---|---|---|
| Load current IC20 mA | RB (3.3 V)2.4 kΩ | IB (3.3 V)1.08 mA | RB (5 V)4.3 kΩ | IB (5 V)1 mA |
| Load current IC50 mA | RB (3.3 V)1 kΩ | IB (3.3 V)2.6 mA | RB (5 V)1.6 kΩ | IB (5 V)2.69 mA |
| Load current IC100 mA | RB (3.3 V)510 Ω | IB (3.3 V)5.1 mA | RB (5 V)820 Ω | IB (5 V)5.24 mA |
| Load current IC200 mA | RB (3.3 V)240 Ω | IB (3.3 V)10.8 mA | RB (5 V)430 Ω | IB (5 V)10 mA |
| Load current IC500 mA | RB (3.3 V)100 Ω ⚠ | IB (3.3 V)26 mA | RB (5 V)160 Ω ⚠ | IB (5 V)26.9 mA |
For hFE 100 with 5× overdrive (forced β = 20) and VBE 0.7 V, rounded down to E24. ⚠ marks base currents over 20 mA, too much for a microcontroller pin. β varies a lot even within one part number: measured β was 259 to 336, about twice the simulation's 129 to 164 (see the β guide). That is why a switch is designed for a low β.
Checked on our bench: real VBE and VCE(sat)
The numbers below are computed from values the site owner recorded in lab classes. Measured values are left exactly as recorded.
A switch base-resistor calculation leans on two assumptions: VBE and VCE(sat). They were checked in the lab on a 2N3904 with the base current held near 20 µA and only the collector resistor changed (VCC 6 V).
| RC | IB | IC | IC ÷ IB | VCE | State |
|---|---|---|---|---|---|
| RC470 Ω | IB19.4 µA | IC7.18 mA | IC ÷ IB371 | VCE2.626 V | Stateactive |
| RC1 kΩ | IB19.2 µA | IC5.8 mA | IC ÷ IB302 | VCE0.196 V | Statesaturated |
| RC1.8 kΩ | IB19.9 µA | IC3.27 mA | IC ÷ IB164 | VCE0.122 V | Statesaturated |
| RC2.7 kΩ | IB20.4 µA | IC2.19 mA | IC ÷ IB107 | VCE0.102 V | Statesaturated |
- VBE was 0.653 to 0.679 V. The calculator's 0.7 V default is slightly high, which errs the safe way: a little more base current flows than calculated.
- VCE(sat) was 0.102 to 0.196 V in the three saturated cases, inside the 0.2 V used for the loss estimate.
- At RC = 470 Ω the switch didn't fully turn on: it needed 12.3 mA, but β·IB only reached 7.18 mA, leaving 2.63 V across it. And that was with a high β: 371, measured in this active-region case.
That is why there is an overdrive factor: the calculator multiplies the base current by k (5 by default) over the minimum hFE. When IC ÷ IB sits near the real β, as in the table, a slightly heavier load drops the switch into the active region. A forced β of 10 to 20, as the defaults give, avoids that. The full measurements are in the BJT bias guide.
Driving a load with a transistor
From load current to a base resistor
- Enter the drive voltage (for example 5 V or 3.3 V from a microcontroller pin), the load current and the transistor's minimum β.
- Read the suggested base resistor and the base current it gives.
- Check that the base current is within what the pin can supply, and that the transistor's collector current rating covers the load.
Switch mistakes: weak drive, no flyback diode
- Using the typical β. For a switch you want hard saturation, so design with a forced β of about 10 to 20 (base current a tenth to a twentieth of the load current), not the datasheet's typical 200.
- No flyback diode on a relay or motor. When the transistor turns off, the coil's stored energy produces a voltage spike that can destroy it. Put a diode across the coil, cathode to the positive supply.
- Overloading the pin. An Arduino Uno pin is rated 40 mA absolute maximum and 20 mA is a sensible working limit. Keep base current well below that.
When to switch to a MOSFET
A saturated small-signal BJT still drops about 0.1 to 0.3 V, which is fine at a few hundred milliamps. Above roughly half an amp, or on battery power where the base current is a real drain, a logic-level N-channel MOSFET is usually the better switch: it needs no steady gate current. Check that its on-resistance is specified at your gate voltage (2.5 V or 4.5 V), not only at 10 V.
Frequently asked questions
Why not just use hFE to size the base current?
hFE varies widely between parts and drops at high current. Designing with the minimum hFE times an overdrive factor (a forced beta of about 10 to 20) makes sure the transistor saturates and runs cool.
Can an Arduino pin drive the base directly?
Yes, through the resistor, as long as the base current stays well within the pin's limit (around 20 mA recommended on an Uno). For larger loads use a logic-level MOSFET or a Darlington.