To use a MOSFET as a switch for a microcontroller, you need a logic-level N-channel MOSFET (like the IRLZ44N or IRLB8721), a 100Ω gate resistor, and a 10kΩ pull-down resistor. This setup allows a 3.3V or 5V GPIO pin to safely toggle high-current 12V or 24V DC loads without frying your development board. Unlike mechanical relays, a solid-state MOSFET switch offers silent, high-speed PWM operation with no moving parts to wear out.
This guide cuts through the semiconductor physics and gives you the exact part numbers, circuit values, and testing procedures you need to build a robust DC switching circuit on the bench today.
Anatomy and Pinout of a Power MOSFET
A Metal-Oxide-Semiconductor Field-Effect Transistor (MOSFET) used for switching has three primary terminals, plus a hidden fourth terminal that causes most beginner headaches:
- Gate (G): The control pin. Voltage applied here (relative to the Source) creates an electric field that opens the channel. It draws virtually zero steady-state current but requires a brief surge of current to charge its internal capacitance.
- Drain (D): The terminal where current enters the load path (for N-channel devices).
- Source (S): The terminal where current exits the load path, typically tied to ground in low-side switching configurations.
- Body Diode: An intrinsic, unavoidable parasitic diode built into the silicon between the Source and Drain. In an N-channel MOSFET, the cathode is at the Drain and the anode is at the Source. If you wire the MOSFET backward, current will flow through this diode even when the Gate is unpowered.
Selecting the Right MOSFET Switch: Logic-Level vs. Standard
The most common mistake makers make is grabbing a standard MOSFET like the IRF520 and wondering why it gets blistering hot when driven by a 3.3V ESP32. Standard MOSFETs require 10V on the gate to fully turn on. For microcontrollers, you must select a logic-level MOSFET, which is guaranteed to reach its lowest on-resistance ($R_{DS(on)}$) at 4.5V or even 2.5V.
When reading a datasheet, ignore the Gate Threshold Voltage ($V_{GS(th)}$). A $V_{GS(th)}$ of 2.0V only means the MOSFET barely starts to conduct (usually at 250µA). Instead, look at the $R_{DS(on)}$ table and find the row that matches your GPIO voltage.
| Part Number | Package | Max $V_{DS}$ | Max $I_D$ | $R_{DS(on)}$ @ 4.5V | Typical Price |
|---|---|---|---|---|---|
| IRLB8721 | TO-220 | 30V | 62A | 4.5 mΩ | $1.20 |
| IRLZ44N | TO-220 | 55V | 47A | 14 mΩ | $0.85 |
| FQP30N06L | TO-220 | 60V | 30A | 35 mΩ | $1.10 |
| AO3400 | SOT-23 | 30V | 5.7A | 27 mΩ | $0.15 |
Note: The IRLB8721 is the undisputed king for 12V/5V high-current loads like LED strips and motors. The AO3400 is perfect for compact PCB designs switching smaller relays or solenoids.
MOSFET Operation Regions for Switching
Terminology between BJTs and MOSFETs is notoriously confusing. In a BJT, "saturation" means fully ON. In a MOSFET, "saturation" means acting as an amplifier. Here is how the regions actually map to switching applications:
| Region | Gate Voltage ($V_{GS}$) | Drain-Source Behavior | Use Case |
|---|---|---|---|
| Cutoff | < $V_{GS(th)}$ | Open circuit (OFF) | Switching OFF |
| Ohmic / Linear | > $V_{GS(th)}$ + Overdrive | Low-value resistor (ON) | Switching ON (Target) |
| Saturation / Active | > $V_{GS(th)}$, low $V_{DS}$ | Constant current source | Amplifiers, Electronic Loads |
For a MOSFET switch, you want to snap instantly between Cutoff and the Ohmic region. Lingering in the Saturation/Active region during turn-on or turn-off causes massive heat dissipation ($P = V_{DS} \times I_D$).
Complete 12V DC Load Application Circuit
This circuit uses an ESP32 (3.3V logic) to PWM-switch a 12V, 5A LED strip using an IRLB8721. According to Espressif's official GPIO documentation, ESP32 pins can safely source up to 40mA, but we will limit the inrush current to protect the silicon.
Components Required
- 1x IRLB8721 (N-Channel Logic-Level MOSFET)
- 1x 100Ω resistor (Gate current limiter)
- 1x 10kΩ resistor (Gate pull-down)
- 1x 1N5819 Schottky diode (Flyback protection)
- 12V DC Power Supply and LED Strip
Wiring Steps
- Tie the grounds: Connect the ESP32 GND to the 12V power supply GND. They must share a common ground reference.
- Install the pull-down: Connect the 10kΩ resistor between the MOSFET Gate and Source (GND). This bleeds off gate charge and keeps the load OFF during ESP32 boot-up.
- Wire the gate resistor: Connect the 100Ω resistor between ESP32 GPIO 18 (or any PWM-capable pin) and the MOSFET Gate.
- Connect the load: Connect the 12V LED strip positive lead to the 12V supply. Connect the negative lead to the MOSFET Drain.
- Complete the circuit: Connect the MOSFET Source to the common GND.
Failure Modes and Multimeter Testing
MOSFETs don't usually age gracefully; they fail catastrophically. The three most common failure modes are:
- Gate Oxide Puncture: Caused by ESD or applying >±20V to the gate. The gate shorts to the source, and the microcontroller pin dies.
- Avalanche Breakdown: Caused by inductive kickback exceeding the $V_{DS}$ rating without a flyback diode. The Drain shorts to the Source.
- Thermal Runaway: Caused by insufficient gate voltage (operating in the linear region) or inadequate heatsinking. The silicon melts and shorts Drain to Source.
How to Test a MOSFET with a Digital Multimeter
You can verify an N-channel MOSFET's health on the bench using your DMM's Diode Test mode. Remove the MOSFET from the circuit first.
- Discharge the gate: Touch the meter probes across the Gate and Source to bleed any stored charge.
- Test the body diode: Place the Red probe on the Source and the Black probe on the Drain. You should read a voltage drop of ~0.4V to 0.6V (the forward bias of the body diode).
- Test reverse blocking: Swap probes (Red on Drain, Black on Source). The meter should read "OL" (Open Loop).
- Charge the gate: Keep the Black probe on the Source. Touch the Red probe to the Gate for one second. This charges the gate capacitance and turns the MOSFET ON.
- Verify the channel: Move the Red probe back to the Drain (Black still on Source). The meter should now read near 0.00V or beep (continuity), indicating the channel is fully enhanced.
- Discharge to turn off: Touch the Gate and Source together again. Re-test Drain to Source; it should return to "OL" in the reverse direction.
If the Drain-Source reads as a dead short in both directions, or if the Gate shows continuity to the Source/Drain, the MOSFET is dead and must be replaced.
Frequently Asked Questions
Can I use a standard IRF520 MOSFET switch with a 3.3V ESP32?
No. The IRF520 is a standard-level MOSFET designed for 10V gate drives. Its $V_{GS(th)}$ can be as high as 4.0V, meaning a 3.3V ESP32 pin might not even turn it on. Even if it partially conducts, it will remain in the high-resistance linear region, acting like a space heater and likely melting your breadboard wires. Always use a logic-level part like the IRLB8721 or IRLZ44N for 3.3V and 5V systems.
Why does my MOSFET switch get hot even at low currents?
If your MOSFET is hot to the touch at currents under 2A, it is likely oscillating or operating in the linear region. First, check that you have a 10kΩ pull-down resistor; without it, the gate acts as an antenna, picking up EMI and rapidly toggling the MOSFET on and off. Second, verify your gate drive voltage. If you are driving a standard MOSFET with 5V, it isn't fully enhanced, and the $R_{DS(on)}$ is much higher than the datasheet headline number.
Do I need a gate resistor for a MOSFET switch?
Yes. A MOSFET gate behaves like a small capacitor (often 1000pF to 3000pF for power devices). When the GPIO pin goes HIGH, it tries to charge this capacitor instantly, resulting in a massive inrush current spike that can degrade or destroy the microcontroller's output driver. A 100Ω to 330Ω resistor limits this inrush current to safe levels (e.g., 3.3V / 100Ω = 33mA) while still allowing the MOSFET to switch fast enough for standard PWM frequencies (up to ~20kHz).
P-channel vs N-channel MOSFET switch: which should I use?
For 95% of maker projects, use an N-channel MOSFET for low-side switching (switching the ground path). N-channel silicon is inherently more efficient, cheaper, and easier to drive directly from a microcontroller. P-channel MOSFETs are used for high-side switching (switching the positive voltage), but a 3.3V microcontroller cannot easily turn off a P-channel MOSFET connected to a 12V rail without an intermediate driver transistor or dedicated gate driver IC. Stick to N-channel low-side unless your load explicitly requires a permanent ground connection (like certain automotive chassis-grounded lights).






