When working through practical semiconductors examples, the most common exam and bench task is sizing a base resistor to drive an inductive load. For a 12V relay with a 120Ω coil driven by a 3.3V microcontroller GPIO using a PN2222A NPN transistor, the correct standard E24 base resistor value is 220Ω. This guarantees hard saturation without exceeding standard GPIO current limits. Below, we walk through the exact algebraic derivation, the common 'beta drop' trap that ruins these circuits, and how to verify your design on the bench.

The Problem Statement: Driving a 12V Relay

Given Parameters:

  • Supply Voltage ($V_{CC}$) = 12.0V DC
  • Relay Coil Resistance ($R_{coil}$) = 120Ω
  • Microcontroller GPIO Output Voltage ($V_{IN}$) = 3.3V
  • Transistor = PN2222A (NPN BJT)

Objective: Calculate the required base resistor ($R_B$) to guarantee the transistor operates in hard saturation as a closed switch, and select the nearest standard E24 resistor value.

Method Selection and the 'Beta Drop' Trap

To solve this, we must use the Forced Beta ($\beta_{forced}$) method combined with load-line analysis. The goal of a switching circuit is to push the transistor out of the active (linear) region and deep into the saturation region, where $V_{CE}$ drops to near zero.

⚠️ The Trap: The most frequent mistake in semiconductor exam problems and hobbyist designs is using the datasheet's active-region DC current gain ($h_{FE}$). The PN2222A datasheet lists an $h_{FE}$ of roughly 100 to 300 at $I_C = 100mA$. If you use $h_{FE} = 100$ to calculate your base current, you will under-drive the base. The transistor will operate in the linear region, acting like a variable resistor rather than a switch. It will dissipate massive heat (often melting the TO-92 package) and fail to pass enough current to pull in the relay armature.

To guarantee saturation, we must intentionally overdrive the base. According to the ON Semiconductor PN2222A datasheet, the saturation test conditions specify a forced beta ratio of $I_C / I_B = 10$. Therefore, we must design for $\beta_{forced} = 10$, regardless of the transistor's higher active-region gain.

Step-by-Step Algebraic Solution

Let's break down the algebra without skipping steps.

Step 1: Calculate the required Collector Current ($I_C$)
When saturated, the voltage drop across the collector-emitter junction ($V_{CE(sat)}$) is typically 0.3V for this transistor at our target current. We apply Ohm's law to the relay coil:

$I_C = (V_{CC} - V_{CE(sat)}) / R_{coil}$
$I_C = (12.0V - 0.3V) / 120\Omega$
$I_C = 11.7V / 120\Omega = 0.0975A$ (or 97.5 mA)

Step 2: Calculate the required Base Current ($I_B$)
Using our forced beta of 10 to guarantee saturation:

$I_B = I_C / \beta_{forced}$
$I_B = 97.5mA / 10 = $ 9.75 mA

Step 3: Determine the Voltage Drop Across the Base Resistor ($V_{RB}$)
The base-emitter junction behaves like a forward-biased diode. However, in hard saturation with nearly 10mA of base current, $V_{BE(sat)}$ rises above the standard 0.7V textbook approximation. The datasheet curves indicate $V_{BE(sat)} \approx 0.9V$ at $I_B = 10mA$.

$V_{RB} = V_{IN} - V_{BE(sat)}$
$V_{RB} = 3.3V - 0.9V = $ 2.4V

Step 4: Calculate the Base Resistor Value ($R_B$)
Applying Ohm's law to the base circuit:

$R_B = V_{RB} / I_B$
$R_B = 2.4V / 0.00975A = $ 246.15 Ω

To guarantee saturation, we must ensure the actual current is at least 9.75mA. Therefore, we must round down to the nearest standard E24 resistor value. The closest standard value below 246Ω is 220Ω.

Sanity Check and Bench Verification

Before soldering, we run a sanity check on power dissipation and GPIO limits, referencing the Espressif ESP32 Datasheet for typical 3.3V logic limits.

  • Resistor Power Dissipation: $P = I^2 \times R = (0.0109A)^2 \times 220\Omega = 0.026W$. A standard 1/4W (0.25W) through-hole resistor is more than adequate.
  • GPIO Current Limit: The actual base current with a 220Ω resistor will be $2.4V / 220\Omega = 10.9mA$. The ESP32 recommends a maximum continuous sink/source current of 11mA per pin (absolute max 40mA). 10.9mA is safe, but leaves little headroom. If using a microcontroller with stricter 4mA GPIO limits (like some older PICs), you would need a MOSFET instead of a BJT.

💡 How to Verify Independently on the Bench:
Build the circuit and command the GPIO HIGH. Set your multimeter to DC Voltage and measure directly across the Collector and Emitter pins of the PN2222A.
- If $V_{CE} < 0.3V$: The transistor is in hard saturation. The design is correct.
- If $V_{CE} > 1.0V$: The transistor is in the active (linear) region. Your base resistor is too large, or your GPIO is sagging under the 11mA load.

Decision Tree: Selecting the Final Resistor

Use this decision matrix to adapt the calculation if your specific exam parameters or bench components change. This table terminates in a concrete E24 pick based on common logic families and relay coils.

GPIO Voltage ($V_{IN}$) Relay Coil Resistance Required $I_B$ (using $\beta=10$) Calculated $R_B$ Final E24 Pick
3.3V 120Ω (100mA coil) 9.75 mA 246 Ω 220 Ω
5.0V 120Ω (100mA coil) 9.75 mA 420 Ω 390 Ω
3.3V 240Ω (50mA coil) 4.87 mA 492 Ω 470 Ω
5.0V 240Ω (50mA coil) 4.87 mA 841 Ω 820 Ω

For deeper theoretical background on load-line analysis and switching regions, the All About Circuits BJT switching tutorial provides excellent visual graphs of the saturation boundary.

Frequently Asked Questions

Why not just use a MOSFET like the 2N7000 instead of a BJT?
For a 100mA relay coil, a logic-level MOSFET is actually a superior choice because it draws zero continuous gate current, eliminating the GPIO current limit concern entirely. However, BJT biasing remains a mandatory academic exercise and is often cheaper in high-volume legacy designs. If your GPIO can only source 2mA, abandon the PN2222A and use a 2N7000 MOSFET with a 10kΩ gate pull-down resistor.

Do I need a flyback diode across the relay coil? Yes, absolutely. A relay coil is an inductor. When the BJT turns off, the collapsing magnetic field generates a massive reverse voltage spike (often >50V) that will instantly punch through the collector-base junction and destroy the PN2222A. Always place a 1N4148 or 1N4007 diode in reverse bias across the coil (cathode to 12V, anode to the collector pin).

What if my calculated resistor value falls exactly on a standard E24 number?
If your math yields exactly 240Ω (an E24 value), you should still step down to the next lower value (220Ω) in a switching application. Component tolerances (typically ±5% for carbon film) and minor voltage sags in the GPIO trace can push you back into the active region. Always bias slightly heavier for switching; bias precisely for linear amplification.