ESP32 C3 Super Mini - MOSFET Module
Learn how to use a MOSFET module with the ESP32 C3 Super Mini to switch a 12V load and set its power level with PWM.

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of MOSFET Module
The problem it solves:
- A GPIO pin on the ESP32 C3 Super Mini gives 3.3V and only a tiny current
- A 12V LED strip, fan, DC motor, pump, solenoid valve or heater needs far more than that
- The MOSFET module lets the small 3.3V signal control the big 12V power path
Three versions, one board design:
- AOD4184 (also sold as D4184), LR7843 and FR120N
- Same size, same pins, same wiring, same code
- Only the MOSFET chip is different
Key specifications:
| AOD4184 | LR7843 | FR120N | |
|---|---|---|---|
| MOSFET chip | AOD4184A (N-channel) | IRLR7843 (N-channel) | IRFR120N (N-channel) |
| Max load voltage (MOSFET rating) | 40V DC | 30V DC | 100V DC |
| Max current (MOSFET rating) | 50A | 161A | 9.4A |
| On-resistance RDS(on) | about 7 mΩ | about 3.3 mΩ | about 210 mΩ |
| Practical current, no heatsink | about 10–15A | about 15A | about 2A |
Shared by all three:
- Control Signal: 3.3V or 5V logic, active HIGH
- Isolation: PC817 optocoupler
- PWM: Supported, keep it at about 1 kHz or lower
- Load Type: DC only
- Library Required: None — uses built-in analogWrite()
MOSFET Module Pinout

Signal header (2 pins, 2.54mm pitch — fits a breadboard):
- PWM — Control input; goes to an ESP32 C3 GPIO pin
- GND — Signal ground; goes to ESP32 C3 GND
Power screw terminals (3 terminals):
- + — Positive of the load power supply (for example 12V) AND positive wire of the load. Both wires go into this one terminal (or join them first)
- LOAD — Negative wire of the load; this is the switched side (MOSFET drain)
- − — Negative (ground) of the load power supply
※ NOTE THAT:
The printed labels can change a little from batch to batch. Always check the silkscreen on your own board.
How It Works Inside
The path of the signal:
- Chain: GPIO4 → PWM pin → small resistor → LED in the PC817 → light → phototransistor in the PC817 → MOSFET gate
- Gate pull-down: a resistor holds the gate at 0V while the PC817 is off
- Low-side switch: the N-channel MOSFET sits between LOAD and −. The load sits between + and LOAD
- Isolated grounds: the ESP32 C3 side and the 12V side are not joined on the module. Signal GND and load GND are separate
The three input states at a glance:
| Input on PWM pin | PC817 LED | MOSFET | Load gets (12V supply) |
|---|---|---|---|
| LOW (0V) | Dark | OFF (open switch) | 0V, no power |
| HIGH (3.3V) | Lit | Fully ON (closed switch) | About 12V, full power |
| PWM signal | Blinks with the signal | ON / OFF very fast | 12V pulses, average set by duty cycle |
State 1 — GPIO LOW → Load OFF
- Code: analogWrite(MOSFET_PIN, 0) or digitalWrite(MOSFET_PIN, LOW)
- Optocoupler: 0V on the pin, so no current reaches the LED. It stays dark
- Gate: the phototransistor stays off, so the pull-down resistor keeps the gate at 0V
- MOSFET: OFF — LOAD and − are not connected
- Load: its − wire has no way to ground. No current, 0V across the load
State 2 — GPIO HIGH → Load ON
- Code: analogWrite(MOSFET_PIN, 255) or digitalWrite(MOSFET_PIN, HIGH)
- Optocoupler: a few mA flow into the LED and it lights up (hidden inside the chip)
- Gate: the phototransistor conducts. The gate gets about half the load supply — about 6V from 12V
- MOSFET: fully ON, like a closed switch. Resistance is a few mΩ (AOD4184, LR7843) or about 0.2Ω (FR120N)
- Current path: adapter + → + → load → LOAD → MOSFET → − → adapter −
- Load: nearly the full 12V, full power
- Why 3.3V is enough: the LED needs only a small current. A 5V board works too
State 3 — PWM Signal → Part Power
- What the pin does: switches LOW/HIGH about 500–1000 times per second
- What the MOSFET does: follows each change — ON in the HIGH part, OFF in the LOW part
- What the load gets: 12V pulses. Average voltage and power = duty cycle × full value
- Duty cycle: the share of time the pin is HIGH. With analogWrite(), duty = value / 255
Example with a 12V supply:
| analogWrite() value | Duty cycle | Time ON | Average voltage | Power |
|---|---|---|---|---|
| 0 | 0% | Never | 0V | None |
| 64 | 25% | 1/4 of the time | about 3V | About 1/4 |
| 128 | 50% | Half the time | about 6V | About 1/2 |
| 191 | 75% | 3/4 of the time | about 9V | About 3/4 |
| 255 | 100% | Always | 12V | Full |
- LED strip: looks dimmer. The flicker is too fast for your eyes
- Motor, fan, pump: turns slower. Its spinning mass smooths the pulses
- Frequency: keep it at about 500 Hz–1 kHz. The PC817 is slow. Too fast, and the MOSFET does not switch fully, the pulses get messy and the MOSFET heats up
- In the code below: the power steps from 10% to 100% in 10% steps
WARNING
- Load supply must be 6V or more. Because of the gate voltage divider, a 5V load supply will not work well. Use 9V or more if the load draws more than a few amps.
- DC only. Never connect AC mains to this module.
- No flyback diode on the board. For a motor, pump, solenoid or relay coil, add a diode (for example 1N5819 or 1N4007) across the load: stripe (cathode) to load +, other end (anode) to load −.
- Never connect 12V to any ESP32 C3 Super Mini pin.
Wiring Diagram between MOSFET Module and ESP32 C3 Super Mini
Here's how to connect the MOSFET module to the ESP32 C3 Super Mini:
| From | To |
|---|---|
| ESP32 C3 Super Mini GPIO4 | Module PWM |
| ESP32 C3 Super Mini GND | Module GND |
| 12V adapter + (through DC power jack) | Module + |
| LED strip + | Module + (same terminal as the adapter +) |
| LED strip − | Module LOAD |
| 12V adapter − (through DC power jack) | Module − |

This image is created using Fritzing. Click to enlarge image
- Signal side: only two short jumper wires
- Power side: screw terminals only — no 12V wire touches the ESP32 C3
- Other loads? See the wiring examples below
Wiring Examples: More 12V Loads
The LED strip is just one option. Here's how to hook up five more loads.
What stays the same for every load:
- ESP32 C3 side: GPIO4 → PWM, GND → GND. This part never changes
- Supply: adapter + → Module +, adapter − → Module −
- Load: load + → Module + (shared with the adapter +), load − → Module LOAD
- Voltage: adapter voltage = load voltage (12V load → 12V adapter). Never below 6V
- Current: FR120N for small loads only (about 2A, no heatsink). AOD4184 or LR7843 for bigger loads
- Code: no change. For a solenoid, drop the fade and use only HIGH and LOW
Quick overview:
| Load | Flyback Diode | What PWM Does |
|---|---|---|
| 12V DC motor | Needed | Speed |
| 12V water pump | Needed | Flow |
| 12V LED strip (single color) | Not needed | Brightness |
| 12V solenoid valve | Needed | Nothing — ON/OFF only |
| 12V cooling fan | Recommended | Speed |
| 12V solenoid lock | Needed | Nothing — ON/OFF only |
Diode direction: the same as in the warning box above — stripe (cathode) on the load + wire, anode on the load − wire.
DC Motor (12V)

This image is created using Fritzing. Click to enlarge image
- Wires: motor + → +, motor − → LOAD
- Diode: yes
- PWM: sets the speed
- Direction: one way only. To reverse it, use a motor driver such as the L298N
Water Pump (12V)

This image is created using Fritzing. Click to enlarge image
- Wires: pump + → +, pump − → LOAD
- Diode: yes
- PWM: sets the flow
- Careful: do not run it without water
LED Strip, Single Color (12V)

This image is created using Fritzing. Click to enlarge image
- Wires: strip + (often labeled 12V) → +, strip − → LOAD
- Diode: not needed — there is no coil
- PWM: sets the brightness
- Current: a long strip draws more. Check it before you choose a module
- Not for: RGB or addressable strips
Solenoid Valve, Normally Closed (12V)

This image is created using Fritzing. Click to enlarge image
- Wires: valve + → +, valve − → LOAD
- Diode: yes
- Control: HIGH = open, LOW = closed. No PWM
Cooling Fan (12V)

This image is created using Fritzing. Click to enlarge image
- Wires: red → +, black → LOAD, yellow (if there is one) → leave free
- Diode: recommended — cheap and safe
- PWM: sets the speed. Start above about 30%, because some fans do not spin at a low duty
Solenoid Lock (12V)

This image is created using Fritzing. Click to enlarge image
- Wires: lock + → +, lock − → LOAD
- Diode: yes
- Control: 100% or 0% only, no dimming
- Heat: pulse it ON just long enough to unlock. It gets hot if you leave it ON
How To Program For MOSFET Module
Here's the code to switch and dim a load with the MOSFET module:
- Pick the GPIO that goes to the PWM pin:
- Make it an output and start with the load OFF:
- Full power ON (255 = 100% duty):
- Set a power level in percent:
- PWM frequency: analogWrite() on the ESP32 C3 runs at 1 kHz by default. This is slow enough for the PC817, so no change is needed.
- Simple ON/OFF only? digitalWrite(MOSFET_PIN, HIGH) and digitalWrite(MOSFET_PIN, LOW) also work.
ESP32 C3 Super Mini Code - MOSFET Module
Detailed Instructions
What this code does:
- Turns the load fully ON for 2 seconds
- Turns the load fully OFF for 2 seconds
- Raises the power from 10% to 100% in 10% steps, every 0.5 seconds
- Lowers the power from 90% back to 0% in the same way
- Waits 1 second, then repeats
- Prints each state to the Serial Monitor at 9600 baud
- First time with this board? Read the Getting Started with ESP32 C3 Super Mini tutorial first.
- Make the wiring shown in the table and diagram above. Leave the 12V adapter unplugged for now.
- Connect the ESP32 C3 Super Mini to your PC with the USB Type-C cable.
- Open Arduino IDE. Choose the ESP32C3 Dev Module board and the correct COM port.
- Copy the code and paste it into Arduino IDE.
- Click Upload.
- If the upload does not start, hold the BOOT button, press and release RESET, then release BOOT and try again.
- Plug in the 12V adapter.
- Open the Serial Monitor and set it to 9600 baud.
- Watch the LED strip: full bright, then dark, then slowly brighter, then slowly dimmer.
Serial Monitor Output
Additional Knowledge
Which module should you buy?
- LR7843: Lowest resistance, stays coolest at high current. Best for 12V/24V loads that draw a lot (bright LED strips, big motors). Max 30V.
- AOD4184: A good all-rounder. Up to 40V with strong current. Fits 12V, 24V and 36V loads.
- FR120N: Highest voltage (up to 100V), but highest resistance. Keep it to small loads, about 2A without a heatsink. Fits 24V/48V small loads.
- About the big numbers: 50A and 161A are chip limits, not board limits. On this small board, heat is the real limit. Touch the chip after a few minutes, and add a heatsink if it gets hot.
MOSFET module or relay?
- MOSFET module: silent, no moving parts, very fast, can do PWM, long life — DC loads only
- Relay: clicks, only full ON or full OFF, but can switch AC. See the ESP32 C3 Super Mini - Relay tutorial.
Related tutorials:
- ESP32 C3 Super Mini - LED - Fade — the same PWM idea on a small LED