Home / Tools / Transistor base resistor calculator

Transistor base resistor calculator

Switch a relay, motor, LED strip or buzzer from a microcontroller pin with an NPN transistor. This works out the base resistor that turns the transistor hard on.

  • Electronics tool
  • Runs in your browser
  • Tested 19 November 2026
  • Sources
The pin's high voltage: 3.3 V for a Pico or ESP32, 5 V for an Arduino Uno.
0.7 to 0.9 V for most small transistors. Check the datasheet.
10 is how datasheets specify saturation.
From the datasheet, at your load current.
For example 20 mA for an Arduino Uno pin.

The formula

To use a bipolar transistor as a switch, you drive it into saturation, so it drops only a few tenths of a volt and stays cool. Datasheets give the saturation voltage VCE(sat) with the base current set to a tenth of the collector current, so a forced gain of 10 is the safe design choice:

IB = IC ÷ 10 and RB = (Vdrive − VBE(sat)) ÷ IB

Pick the next standard value below the result, so the base gets at least the current you designed for.

Worked example. A 100 mA relay coil from a 3.3 V pin. IB = 100 ÷ 10 = 10 mA. RB = (3.3 − 0.7) ÷ 0.010 = 260 Ω, so use 240 Ω (E24), giving about 10.8 mA.

Check the pin can supply it

10 mA is a lot to ask of some microcontroller pins. An Arduino Uno pin is fine: the ATmega328P's absolute maximum is 40 mA per pin, and 20 mA is the usual design limit. A Raspberry Pi Pico pin is set to 4 mA drive strength by default, and its voltage sags if you draw more. For loads over about 100 mA from a 3.3 V board, a logic-level MOSFET is usually the better choice: its gate draws almost no current. See transistors as switches.

Things to know

  • If you only need a light load, you can use a lower forced gain, as long as the base current is at least two or three times IC ÷ hFE(min). The tool shows that margin.
  • Relay coils, motors and solenoids need a flyback diode across them (cathode to the positive supply), or the voltage spike at switch-off can destroy the transistor.
  • Check the transistor's maximum collector current and power: P ≈ VCE(sat) × IC.
  • Put the load between the supply and the collector, with the emitter to ground (low-side switching). The grounds must be common.

Sources

Where the formulas and figures on this page come from. We test every tool against worked examples from these before publishing.