The Direct Answer: Which Transistor to Use as a Switch?
If you are bridging low-voltage smart home logic (like an ESP32 or Arduino) to control home electrical hardware—such as a 24V HVAC contactor coil, a subpanel shunt trip breaker, or a heavy-duty lighting relay—you need a component that can handle inductive kickback and fully saturate at logic-level voltages.
The short answer: For load currents under 500mA driven by 5V logic, use a 2N2222 NPN BJT. For load currents over 500mA, or if you are driving the switch from 3.3V logic (like an ESP32-WROOM-32), use a logic-level N-channel MOSFET like the IRLB8721 or IRLZ44N. Never use a standard power MOSFET like the IRF520 for 3.3V logic; it will not fully turn on, leading to thermal failure.
Pinouts and Operation Regions: BJT vs. MOSFET
To use a transistor as a switch, you must drive it into its fully "ON" state (saturation for BJTs, ohmic/linear region for MOSFETs) so it acts like a closed mechanical switch with minimal voltage drop.
Pinout and Symbol Descriptions
- BJT (Bipolar Junction Transistor): The Base (B) is the control pin, requiring a continuous current to keep the switch closed. Current flows from the Collector (C) to the Emitter (E). In schematics, the arrow on the emitter points outward for NPN types.
- MOSFET (Metal-Oxide-Semiconductor Field-Effect Transistor): The Gate (G) is the control pin, requiring voltage but virtually zero continuous current. Current flows from the Drain (D) to the Source (S). The symbol features a solid line for the channel and an arrow on the source indicating current direction.
Operation Regions Table
| Region | BJT (NPN) State | MOSFET (N-Channel) State | Typical Control Voltage/Current | Switch Application Status |
|---|---|---|---|---|
| Cutoff | OFF (Vbe < 0.7V) | OFF (Vgs < Vth) | 0V / 0mA | Open Switch (Load OFF) |
| Active / Linear | Amplifying (Varying Vce) | Constant Current (Vds > Vgs-Vth) | Partial Base current / Vgs > Vth | Avoid (High heat dissipation) |
| Saturation / Ohmic | ON (Vce ≈ 0.2V) | ON (Rds(on) is minimal) | Ib > Ic/hFE / Vgs ≥ 4.5V | Closed Switch (Load ON) |
Decision Tree: Sizing the Transistor for Relay and Contactor Coils
When wiring a smart controller to home electrical gear, you are almost always switching an inductive coil. Use this decision path to select your exact component.
| Condition | Logic Voltage | Load Current | Concrete Pick (Part Number) |
|---|---|---|---|
| Small 5V relay module | 5.0V | < 100mA | 2N2222 (NPN BJT) |
| 12V lighting contactor coil | 5.0V | 100mA - 500mA | TIP120 (Darlington BJT) |
| 24V HVAC contactor / Shunt Trip | 3.3V (ESP32) | > 500mA | IRLB8721 (Logic-Level MOSFET) |
| High-current 12V linear actuator | 5.0V | > 5A | IRLZ44N (Logic-Level MOSFET) |
Final Default Recommendation: If you are building a custom smart-home panel using an ESP32 to drive standard 24V Eaton or Square D shunt-trip breakers (which typically pull 0.8A to 1.2A momentarily), standardize your BOM on the IRLB8721. It has an ultra-low Rds(on) at 3.3V gate drive and handles up to 62A, meaning it will run stone-cold on a 1A coil load without a heatsink.
The Complete Application Circuit: Driving a 24V Contactor Coil
Below is a complete, bench-tested circuit for switching a 24V home electrical contactor coil using an ESP32 (3.3V logic). This setup includes the critical pull-down and flyback components required to prevent phantom triggering and inductive voltage spikes.
Bill of Materials
- Q1: IRLB8721 N-Channel Logic-Level MOSFET
- R1 (Gate Resistor): 100Ω (limits inrush current into the gate capacitance)
- R2 (Pull-down Resistor): 10kΩ (keeps gate at 0V during ESP32 boot-up to prevent the contactor from chattering)
- D1 (Flyback Diode): 1N4007 (rated for 1000V, 1A)
- Load: 24V DC Contactor Coil (e.g., HVAC or subpanel shunt trip)
Wiring Steps
- Gate Drive: Connect ESP32 GPIO pin to one leg of the 100Ω resistor (R1). Connect the other leg of R1 to the Gate (Pin 1) of the IRLB8721.
- Pull-Down: Connect the 10kΩ resistor (R2) between the Gate (Pin 1) and Source (Pin 3) of the MOSFET.
- Ground Reference: Connect the Source (Pin 3) to the common ground shared by your ESP32 and your 24V DC power supply.
- Load Connection: Connect one side of the 24V contactor coil to the positive terminal of the 24V power supply. Connect the other side of the coil to the Drain (Pin 2) of the MOSFET.
- Flyback Protection: Place the 1N4007 diode in parallel with the coil. The cathode (silver stripe) must point toward the 24V positive supply, and the anode must point toward the MOSFET Drain. Do not skip this step; inductive kickback will instantly punch through the MOSFET's drain-source junction.
How Transistors Fail and How to Test Them with a Multimeter
Transistors rarely fail without a reason. Understanding the failure modes saves you from replacing a good part or repeatedly blowing up new ones.
Common Failure Modes
- Thermal Runaway (BJT): As a BJT heats up, its base-emitter voltage drop decreases, causing it to draw more base current, which creates more heat. This ends in a melted junction and a short circuit.
- Gate Oxide Puncture (MOSFET): The gate of a MOSFET is separated from the channel by a microscopic layer of silicon dioxide. Static discharge (ESD) or voltage spikes exceeding ±20V on the gate will punch a hole through this oxide, permanently shorting the gate to the source.
- Avalanche Breakdown: If a flyback diode is omitted, the collapsing magnetic field of a contactor coil generates a high-voltage spike. If this exceeds the MOSFET's Vds rating (e.g., 30V), the transistor avalanches and shorts drain-to-source.
Multimeter Testing Procedure (Diode Test Mode)
Set your digital multimeter to the diode test setting (the symbol with an arrow and a line).
Testing an NPN BJT (e.g., 2N2222):
- Place the red probe on the Base and the black probe on the Emitter. You should read a forward voltage drop of 0.6V to 0.8V.
- Move the black probe to the Collector. You should read a similar 0.6V to 0.8V drop.
- Reverse the probes (black on Base, red on Emitter/Collector). The meter should read "OL" (Open Loop). If it reads near 0.00V, the junction is shorted and the BJT is dead.
Testing an N-Channel MOSFET (e.g., IRLB8721):
- Short all three pins together with your finger or a wire to discharge any residual gate capacitance.
- Place the black probe on the Source and the red probe on the Drain. It should read "OL".
- Keep the black probe on the Source, and touch the red probe to the Gate. This charges the gate capacitance and turns the MOSFET on.
- Move the red probe back to the Drain. The meter should now read a very low voltage drop (near 0.00V to 0.05V), indicating the channel is conducting.
- Touch the Gate to the Source to discharge it. The Drain-Source path should return to "OL". If it stays at 0.00V after discharging, the MOSFET is shorted.
Safe Default Part Numbers and Ratings
When designing a control board for home electrical automation, stick to these proven, widely available part numbers. They are selected for their robust safe operating areas (SOA) and beginner-friendly through-hole (TO-220) packages.
| Part Number | Type | Max Vds / Vce | Max Id / Ic | Key Switching Spec | Best Application |
|---|---|---|---|---|---|
| 2N2222 | NPN BJT | 40V | 800mA | hFE ≈ 100-300 | 5V logic driving small <200mA 12V relays. |
| TIP120 | Darlington BJT | 60V | 5A | High hFE (≈1000), high Vce(sat) (~2V) | 5V logic driving medium loads. Note: Requires a heatsink due to 2V saturation drop. |
| IRLB8721 | N-Ch MOSFET | 30V | 62A | Rds(on) = 7.8mΩ @ Vgs 3.3V | 3.3V ESP32 logic driving 12V/24V contactors and shunt trips. |
| IRLZ44N | N-Ch MOSFET | 55V | 47A | Rds(on) = 22mΩ @ Vgs 4.0V | 5V logic driving high-current 12V/24V DC motors or large solenoid locks. |
By standardizing on the IRLB8721 for your 3.3V smart-home contactor drivers, you eliminate the guesswork of gate threshold voltages and ensure your home electrical switching circuits remain reliable, cool, and safe for years of continuous operation. For deeper reading on MOSFET gate drive principles and inductive kickback protection, refer to the SparkFun Transistor Switching Tutorial and the All About Circuits semiconductor guide.






