Bipolar junction transistors (BJTs) are current-controlled semiconductor devices that act as the fundamental building blocks for switching and amplification in analog and digital circuits. Unlike MOSFETs, which are voltage-controlled, a BJT requires a continuous base current to maintain conduction between the collector and emitter. If you need a reliable, low-cost NPN switch for a 3.3V or 5V microcontroller project, the 2N3904 is your safe default. For high-side PNP switching, use the 2N3906. If you need to push closer to 800mA in a through-hole package, step up to the 2N2222.

This guide skips the abstract semiconductor physics and focuses on what you actually need at the workbench: which part to grab from the bin, how to calculate the base resistor so your ESP32 doesn't brown out, and how to verify a suspect transistor with a digital multimeter.

The Safe Defaults: BJT Part Numbers and Absolute Maximum Ratings

The biggest mistake hobbyists make is selecting a BJT based solely on its current rating without checking the power dissipation or the DC current gain (hFE) at their specific operating point. Below are the workhorse BJTs you should keep stocked in your lab. These parts are universally available, cost pennies in bulk, and have well-documented behaviors.

Table 1: Workhorse BJT Defaults and Absolute Maximum Ratings
Part Number Type VCEO (max) IC (max) PD (max) hFE (min @ 10mA) Primary Use Case
2N3904 NPN 40V 200mA 625mW 100 General purpose logic switching, small signal amp
2N3906 PNP -40V -200mA 625mW 100 High-side switching, complementary to 2N3904
2N2222A NPN 40V 800mA 625mW 100 Medium current loads (relays, small motors)
BC547 NPN 45V 100mA 500mW 110 Low-noise audio preamps, sensor interfacing
TIP120 NPN Darlington 60V 5A 65W (w/ heatsink) 1000 High current DC motors, LED strips, solenoids
Callout Tip: The hFE Trap
Never design a switching circuit relying on the typical or maximum hFE listed in a datasheet. hFE varies wildly with temperature and collector current. For hard switching (saturation), always assume a "forced beta" of 10 to 20. This means you deliberately supply 1/10th of the required collector current into the base to guarantee the transistor turns fully on, regardless of manufacturing tolerances.

Pinouts, Symbols, and the Four Operating Regions

A BJT has three terminals: the Emitter (E), Base (B), and Collector (C). In circuit schematics, the NPN symbol features an arrow on the emitter pointing outward (Not Pointing iN), while the PNP arrow points inward.

The TO-92 Pinout Gotcha: If you hold a standard US-spec 2N3904 or 2N2222 TO-92 package with the flat face toward you and the leads pointing down, the pins from left to right are Emitter, Base, Collector (E-B-C). However, if you buy a European BC547 in the same TO-92 package, the pinout is Collector, Base, Emitter (C-B-E). Always verify the pinout against the specific manufacturer's datasheet before soldering.

Depending on how you bias the Base-Emitter (BE) and Base-Collector (BC) junctions, the transistor operates in one of four distinct regions. For 95% of DIY and hobbyist applications, you only care about Cutoff and Saturation.

Table 2: BJT Operating Regions and Junction Bias States
Operating Region BE Junction BC Junction Typical VCE Application
Cutoff Reverse / Zero (VBE < 0.5V) Reverse VCC (Supply Voltage) Switch OFF (Open circuit)
Forward Active Forward (VBE ≈ 0.7V) Reverse 1.0V to VCC Linear amplification, current mirrors
Saturation Forward (VBE ≈ 0.7V) Forward VCE(sat) ≈ 0.1V - 0.3V Switch ON (Closed circuit)
Reverse Active Reverse Forward N/A Rarely used; very low gain

Designing the Bias Network: A Complete 12V Relay Driver Circuit

Let's build a practical circuit: driving a 12V, 75mA relay coil using a 3.3V GPIO pin from an ESP32. We will use the 2N2222A NPN transistor. According to the ON Semiconductor 2N2222A datasheet, the absolute maximum continuous collector current is 800mA, so our 75mA load is well within the safe operating area.

Step 1: Calculate the Base Resistor (RB)
We want the transistor in hard saturation. We will use a forced beta (overdrive factor) of 10.
Required Base Current (IB) = IC / 10 = 75mA / 10 = 7.5mA.
The ESP32 GPIO outputs 3.3V. The Base-Emitter junction drops approximately 0.7V when forward-biased.
Voltage across RB = 3.3V - 0.7V = 2.6V.
RB = 2.6V / 7.5mA = 346Ω.
Selection: Choose the next lower standard E12 resistor value to ensure enough base current. Use a 330Ω resistor.

Step 2: The Flyback Diode (Critical)
A relay coil is an inductor. When the transistor turns off, the collapsing magnetic field generates a massive reverse voltage spike (flyback voltage) that will instantly avalanche the BJT's collector-base junction, destroying it. You must place a 1N4148 or 1N4007 diode in reverse bias across the relay coil (cathode to 12V, anode to the collector).

Step 3: Verify Power Dissipation
In saturation, VCE(sat) for a 2N2222 at 75mA is roughly 0.3V.
Power dissipated by the transistor (PD) = VCE(sat) × IC = 0.3V × 0.075A = 22.5mW.
Since the TO-92 package can handle up to 625mW at room temperature, no heatsink is required. For a deeper look at BJT switching characteristics and load line analysis, Electronics Tutorials provides excellent visual breakdowns of the saturation region.

Summary Card: The 12V Relay Driver Parts List
  • Q1: 2N2222A (NPN BJT, TO-92)
  • R1 (Base): 330Ω (1/4W, 5% tolerance)
  • D1 (Flyback): 1N4148 signal diode
  • Load: 12V DC Relay (75mA coil)

How BJTs Fail and How to Test Them with a Multimeter

BJTs are rugged, but they have specific failure modes that differ from MOSFETs. Understanding these helps you diagnose a dead board.

  • Secondary Breakdown (Thermal Runaway): Unlike MOSFETs, BJTs have a negative temperature coefficient for VBE. As they get hot, they draw more base current for the same voltage, which makes them hotter, leading to a localized hot-spot that melts the silicon die. This usually results in a dead short between Collector and Emitter.
  • The VEBO Trap: The Base-Emitter junction is heavily doped. Its reverse breakdown voltage (VEBO) is typically only 5V to 6V. If you accidentally apply 12V reverse across the BE junction, it enters Zener breakdown. While this doesn't always destroy the part instantly, it permanently degrades the hFE (current gain), making the transistor useless for amplification.
  • Overvoltage Avalanche: Exceeding VCEO (Collector-Emitter voltage with base open) causes the collector-base junction to avalanche, usually shorting the C-E path.

Testing a BJT with a Digital Multimeter (Diode Mode)

You can verify the health of an NPN or PNP transistor out-of-circuit using the diode test setting on your multimeter. An NPN transistor behaves exactly like two diodes sharing a common anode (the Base).

  1. Set the meter: Turn your multimeter to the Diode Test mode (usually indicated by a diode symbol).
  2. Test Base to Emitter (Forward): Place the Red probe on the Base and the Black probe on the Emitter. You should read a forward voltage drop between 0.55V and 0.75V.
  3. Test Base to Collector (Forward): Place the Red probe on the Base and the Black probe on the Collector. You should again read 0.55V to 0.75V (often slightly lower than the BE reading due to different doping profiles).
  4. Test Reverse Bias: Swap the probes (Black on Base, Red on Emitter/Collector). The meter should read OL (Open Loop / Overload) on both junctions.
  5. Test Collector to Emitter: Place probes across C and E in both directions. The meter must read OL. If you read a short (0.00V or a very low resistance) in either direction, the transistor has suffered secondary breakdown or thermal failure and belongs in the trash.

Note on In-Circuit Testing: Testing a BJT while it is still soldered to a PCB is unreliable. Parallel resistors and protection diodes will skew your multimeter readings, often making a good transistor look shorted or leaky. Always desolder at least the Base leg to lift it off the pad before performing a definitive diode test.

By keeping a bin of 2N3904s and 2N2222s, respecting the forced-beta rule for base resistors, and never forgetting the flyback diode on inductive loads, bipolar junction transistors will remain one of the most reliable and predictable tools in your electronics arsenal.