When you need to switch a load or amplify a signal, picking the right semiconductor is the difference between a circuit that works on the first try and one that melts your microcontroller. The two main types of transistor you will encounter on the bench are the Bipolar Junction Transistor (BJT) and the Metal-Oxide-Semiconductor Field-Effect Transistor (MOSFET). While both act as electrically controlled valves, they operate on fundamentally different principles and require entirely different drive circuits.

The direct answer for most hobbyist and DIY applications is this: use a logic-level N-channel MOSFET for switching loads over 200mA from a 3.3V or 5V microcontroller, and use a small-signal NPN BJT for low-current switching (<200mA) or linear analog amplification. Below is the exact decision framework, biasing math, and testing procedures to get your circuit working.

The Decision Tree: Picking the Right Transistor Type

Stop guessing based on what is in your junk bin. Use this decision matrix to select the correct device for your specific load and control signal.

Your Scenario Control Signal Load Current Concrete Part Pick
Low-power switching (LEDs, small relays) 5V / 3.3V GPIO < 200mA 2N2222 (NPN BJT) or 2N7000 (N-CH MOSFET)
Medium/High-power switching (Motors, heaters, large relays) 5V / 3.3V GPIO 1A to 10A IRLZ44N (Logic-level N-CH MOSFET)
High-side switching (Load connected to ground, switch on VCC) 5V / 12V Varies IRF9540N (P-CH MOSFET) or 2N2907 (PNP BJT)
Linear amplification (Audio pre-amps, current mirrors) Analog bias network < 100mA 2N3904 (NPN) / 2N3906 (PNP)
Bench Tip: Never use a standard MOSFET like the IRF520 with a 3.3V ESP32 or Raspberry Pi. The IRF520 requires 10V on the gate to fully turn on. At 3.3V, it operates in its linear region, acts like a high-value resistor, and will overheat and fail. Always look for the 'L' in the part number (e.g., IRLZ44N) or check the datasheet for a Gate Threshold Voltage (Vgs(th)) under 2.5V.

BJT vs. MOSFET: Pinouts, Symbols, and Operation Regions

To wire these correctly, you need to know their physical pinouts and how they transition between off, amplifying, and fully on.

Pinout Identification

  • BJT (TO-92 Package): Hold the flat side facing you with the legs pointing down. The pins from left to right are Emitter (E), Base (B), Collector (C). The Base is the control terminal; current flows from Collector to Emitter (for NPN).
  • MOSFET (TO-220 Package): Hold the metal tab facing away from you with the legs pointing down. The pins from left to right are Gate (G), Drain (D), Source (S). The Gate is the control terminal; current flows from Drain to Source (for N-channel). The metal tab is internally connected to the Drain.

Operation Regions Table

Region BJT (NPN) Condition MOSFET (N-CH) Condition Practical Use
Cutoff (OFF) Vbe < 0.6V Vgs < Vgs(th) Open switch. No current flows.
Active / Linear Vbe ≈ 0.7V, Vce > 0.2V Vgs > Vgs(th), Vds > (Vgs - Vth) Amplifier. Acts as a current source or variable resistor. High heat dissipation.
Saturation / Ohmic (ON) Vbe ≈ 0.7V, Vce ≈ 0.2V Vgs >> Vgs(th), Vds is minimal Closed switch. Minimal voltage drop, low heat. Use this for digital switching.

Biasing the Device: A Complete 12V Relay Driver Circuit

Let's build a concrete application: driving a 12V automotive-style relay (80mA coil current) using a 3.3V GPIO pin from an ESP32. We will use a 2N2222 NPN BJT.

A common mistake is using the datasheet's maximum hFE (current gain) to calculate the base resistor. In switching applications, we use a forced beta (typically 10 to 20) to guarantee the BJT enters hard saturation, minimizing the Vce voltage drop and keeping the transistor cool.

The Math and Component Values

  1. Target Collector Current (Ic): 80mA (relay coil).
  2. Forced Beta (hFE): 20 (to ensure hard saturation).
  3. Required Base Current (Ib): Ic / Beta = 80mA / 20 = 4mA.
  4. Base Resistor (Rb): The ESP32 outputs 3.3V. The BJT Base-Emitter junction drops about 0.7V. Voltage across resistor = 3.3V - 0.7V = 2.6V.
    Rb = V / I = 2.6V / 0.004A = 650 Ohms.
  5. Standard Value Selection: Step down to the nearest standard E12 value to provide slightly more drive. Use a 470 Ohm resistor. This yields 5.5mA of base current, which is perfectly safe for the ESP32's 40mA absolute max GPIO limit, and drives the 2N2222 deep into saturation.

Complete Circuit Wiring

  • ESP32 GPIO → 470Ω Resistor → 2N2222 Base
  • 2N2222 EmitterSystem Ground
  • 12V Power Supply (+)Relay Coil Pin 1
  • Relay Coil Pin 22N2222 Collector
  • Flyback Diode (1N4007): Cathode (stripe) to Relay Coil Pin 1 (12V), Anode to Relay Coil Pin 2 (Collector). Never omit this; the inductive kickback will instantly punch through the BJT's collector-emitter junction.

How Transistors Fail and How to Test Them with a Multimeter

Transistors rarely fail gracefully. BJTs typically fail due to secondary breakdown (exceeding the Safe Operating Area in the linear region) or thermal runaway. MOSFETs usually die from gate oxide punch-through caused by Electrostatic Discharge (ESD) or exceeding the maximum Vgs rating (usually ±20V), resulting in a dead short between all three pins.

Here is how to verify a device on your bench using a standard digital multimeter (DMM).

Testing a BJT (NPN)

  1. Set your DMM to Diode Test Mode.
  2. Place the Red probe on the Base and the Black probe on the Emitter. You should read a forward voltage drop between 0.600V and 0.750V.
  3. Move the Black probe to the Collector (Red still on Base). You should read a similar drop (0.600V - 0.750V), usually slightly lower than the B-E reading.
  4. Reverse the probes (Black on Base, Red on Emitter/Collector). The meter should read OL (Over Limit) in both cases.
  5. Measure across Collector and Emitter in both directions. Both must read OL. If you read a short (near 0V), the BJT is blown.

Testing a MOSFET (N-Channel)

  1. Set DMM to Diode Test Mode.
  2. Measure between Gate and Source, and Gate and Drain in both directions. All readings must be OL. If you read continuity, the gate oxide is punctured; throw it away.
  3. Measure Drain to Source with the Red probe on Drain and Black on Source. It should read OL.
  4. Reverse the probes (Red on Source, Black on Drain). You should read a voltage drop of roughly 0.400V to 0.600V. This is the internal body diode.
  5. The Turn-On Test: While keeping the Black probe on the Source, briefly touch the Red probe to the Gate to charge it via the DMM's internal battery. Move the Red probe back to the Drain. The meter should now read near 0.00V (continuity), proving the channel has turned on. Touch a finger across Gate and Source to discharge it, and it should revert to OL.

The 'Safe Default' Parts Bin: Exact Part Numbers and Ratings

Stop buying random assortments from unverified marketplace sellers. Stock these specific, industry-standard part numbers from reputable distributors like Digi-Key, Mouser, or Arrow. These cover 95% of bench prototyping needs.

Part Number Type Max Vds / Vceo Max Id / Ic Key Characteristic & Package
2N3904 NPN BJT 40V 200mA Best for small-signal amplification and low-current switching. TO-92.
2N2222 (or P2N2222A) NPN BJT 40V 800mA The universal workhorse for driving relays and LEDs from logic. TO-92 / TO-18.
2N7000 N-CH MOSFET 60V 200mA Great for 5V logic switching of small loads. Avoid for 3.3V logic (Vgs(th) is borderline). TO-92.
IRLZ44N N-CH MOSFET 55V 47A True logic-level. Fully enhanced at 3.3V/5V. Ideal for motors, solenoids, and high-current PWM. TO-220.
IRF9540N P-CH MOSFET -55V -23A Standard high-side switch. Requires a gate drive pulled to the positive rail to turn off. TO-220.
A Warning on the TIP120 Darlington: Many beginner kits include the TIP120 NPN Darlington transistor for switching motors. While it boasts a 5A rating and massive current gain, it has a terrible Collector-Emitter saturation voltage (Vce(sat)) of 2.0V to 4.0V at high currents. If you switch a 3A motor through a TIP120, it will dissipate roughly 6W to 12W of heat as waste, requiring a massive heatsink. For any load over 500mA, replace the TIP120 with an IRLZ44N MOSFET, which has an Rds(on) of 22 milliohms and will dissipate less than 0.2W at 3A without a heatsink.

For authoritative specifications and Safe Operating Area (SOA) graphs, always consult the original manufacturer datasheets, such as the ON Semiconductor P2N2222A datasheet and the Infineon IRLZ44N datasheet. For deeper theory on semiconductor junction testing, the All About Circuits transistor testing guide remains an excellent bench reference.