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.

ESP32 C3 Super Mini - AOD4184, LR7843 or FR120N MOSFET Module

Hardware Preparation

1×ESP32 C3 Super Mini
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×Optionally, DC Power Jack
1×MOSFET Module (AOD4184, LR7843 or FR120N)
1×12V LED Strip
1×Alternatively, 12V DC Cooling Fan
1×12V Power Adapter
1×DC Power Jack (for the 12V load)
1×Jumper Wires

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
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

AOD4184, LR7843 and FR120N 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 −
The wiring diagram between ESP32 C3 Super Mini  with AOD4184, LR7843 or FR120N MOSFET 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)

The wiring diagram between 12V DC motor and MOSFET module

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)

Water pump 12V wired through the MOSFET module

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)

MOSFET module 12V LED strip power wiring

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)

12V normally closed solenoid valve on the MOSFET module

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)

MOSFET module cooling fan wiring, 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)

12V solenoid lock wiring with the MOSFET module

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:
const int MOSFET_PIN = 4;
  • Make it an output and start with the load OFF:
pinMode(MOSFET_PIN, OUTPUT); analogWrite(MOSFET_PIN, 0);
  • Full power ON (255 = 100% duty):
analogWrite(MOSFET_PIN, 255);
  • Set a power level in percent:
int duty = map(percent, 0, 100, 0, 255); analogWrite(MOSFET_PIN, duty);
  • 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

/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-mosfet-module */ const int MOSFET_PIN = 4; // ESP32 C3 Super Mini GPIO4 connected to the PWM pin of the MOSFET module void setup() { Serial.begin(9600); pinMode(MOSFET_PIN, OUTPUT); analogWrite(MOSFET_PIN, 0); // start with the load OFF } void setLoad(int percent) { int duty = map(percent, 0, 100, 0, 255); // convert 0-100% to 0-255 analogWrite(MOSFET_PIN, duty); Serial.print("Load power: "); Serial.print(percent); Serial.println("%"); } void loop() { // turn the load fully ON, then fully OFF Serial.println("Load: ON"); setLoad(100); delay(2000); Serial.println("Load: OFF"); setLoad(0); delay(2000); // increase the power step by step (PWM) for (int percent = 10; percent <= 100; percent += 10) { setLoad(percent); delay(500); } // decrease the power step by step (PWM) for (int percent = 90; percent >= 0; percent -= 10) { setLoad(percent); delay(500); } delay(1000); }

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
  1. First time with this board? Read the Getting Started with ESP32 C3 Super Mini tutorial first.
  2. Make the wiring shown in the table and diagram above. Leave the 12V adapter unplugged for now.
  3. Connect the ESP32 C3 Super Mini to your PC with the USB Type-C cable.
  4. Open Arduino IDE. Choose the ESP32C3 Dev Module board and the correct COM port.
  5. Copy the code and paste it into Arduino IDE.
  6. Click Upload.
  7. If the upload does not start, hold the BOOT button, press and release RESET, then release BOOT and try again.
  8. Plug in the 12V adapter.
  9. Open the Serial Monitor and set it to 9600 baud.
  10. Watch the LED strip: full bright, then dark, then slowly brighter, then slowly dimmer.

Serial Monitor Output

∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32C3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32C3 Dev Module' on 'COM15')
New Line
9600 baud
Load: ON Load power: 100% Load: OFF Load power: 0% Load power: 10% Load power: 20% Load power: 30% Load power: 40% Load power: 50% Load power: 60% Load power: 70% Load power: 80% Load power: 90% Load power: 100% Load power: 90% Load power: 80% Load power: 70% Load power: 60% Load power: 50% Load power: 40% Load power: 30% Load power: 20% Load power: 10% Load power: 0%
Ln 11, Col 1
ESP32C3 Dev Module on COM15
2

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:

Video Tutorial

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!