ESP32 S3 UNO - Control Pump
This ESP32 S3 Uno pump tutorial shows you how to wire a 12V water pump through a relay and turn it on and off with Arduino code. The ESP32 S3 Uno form board cannot drive the pump by itself, so the relay switches the pump's own 12V supply. You can use this idea for plant watering, an aquarium, or a water refill station.
In this tutorial, you will:
- Learn the pinout of a 12V water pump
- Wire a 12V pump and a relay module to the ESP32 S3 Uno
- Write Arduino code to turn the pump on and off
- Upload the code from Arduino IDE and test the pump
- Try a MOSFET module instead of the relay, so you can also change how fast the pump moves water
Why two ways? With a relay, the pump is either running or stopped. With a MOSFET module, you get the same ON and OFF, but you can also lower or raise the flow with PWM, and the switching makes no noise.

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 12V Pump
A small 12V pump moves water through a vinyl tube when it gets power. It is easy to use, but it needs much more power than a board pin can give. Knowing its pins helps you wire it the right way.
Pinout

A 12V pump usually has just two pins. The black wire is the negative (-) pin, and it goes to GND of the DC power supply. The red wire is the positive (+) pin, and it goes to the 12V output of the power supply.
How to Control Pump
When you connect the pump to a 12V supply, it simply runs. To turn it on and off from code, you need a switch that the board can control.
Why use a relay
The ESP32 S3 Uno pins give only 3.3V and a small current, so they cannot run the pump. A relay sits between the board and the pump. The board sends a small signal to the relay, and the relay connects or cuts the pump's 12V power. If relays are new to you, read the ESP32 S3 Uno - Relay tutorial first. It explains the relay pinout, how it works, and how to program it.
Why use a MOSFET module
A MOSFET module is a quiet, electronic switch for DC loads. It can also send PWM to the pump. To see how the module works and how its terminals are wired, check the ESP32 S3 Uno - MOSFET Module guide.
Relay vs MOSFET Module for Pump
| Relay | MOSFET Module | |
|---|---|---|
| Pump control | ON and OFF | ON and OFF, plus flow (pump speed) with PWM |
| Switching sound | audible click | none |
| How fast it switches | slow, milliseconds | very fast |
| Lifetime | contacts slowly wear out | no moving parts to wear |
| Pump type | AC or DC pumps | DC pumps only |
| Pump supply | as the relay rating allows | at least about 6V, so the gate turns on |
| Isolation from the ESP32 S3 Uno | yes (coil and contacts) | yes (PC817 optocoupler) |
| Pick it for | AC pumps, simple ON/OFF | DC pumps, flow control, frequent switching |
For a 12V DC water pump, the MOSFET module gives you more: you can water plants gently instead of at full blast. The relay is still the right part for an AC (mains) pump.
ESP32 S3 Uno Pinout
The image below shows the pinout diagram of the ESP32 S3 Uno form board. Use it to find the Uno header pins (D3, 5V, GND…) and their GPIO numbers when you wire the pump circuit.

Wiring Diagram
The relay input goes to D3 (GPIO17). The pump and the 12V power adapter connect through the relay's screw terminals.

This image is created using Fritzing. Click to enlarge image
| Component Pin | ESP32 S3 Uno Pin |
|---|---|
| Relay VCC | 5V |
| Relay GND | GND |
| Relay IN | D3 (GPIO17) |
On the high-power side, connect the positive wire of the 12V power adapter (through the DC power jack) to the relay COM terminal. Connect the relay NO terminal to the pump's red (+) wire. Connect the pump's black (-) wire to the negative wire of the power adapter.
WARNING
Never connect the 12V supply to the ESP32 S3 Uno pins. The 12V power must only go to the relay terminals and the pump. The ESP32 S3 Uno pins work at 3.3V and are NOT 5V tolerant. The relay module may use 5V on its VCC pin, because its IN pin only receives a signal from the board.
ESP32 S3 Uno Code
This sketch turns the pump on for five seconds and then off for five seconds, again and again. It sets D3 (GPIO17) as an output and writes HIGH or LOW to it to switch the relay.
Detailed Instructions
Do these steps in order:
- New to the ESP32 S3 Uno? Follow ESP32 S3 Uno - Getting Started first.
- Wire it up as shown in the diagram.
- Connect the board to your computer with a USB Type-C cable.
- Open Arduino IDE, choose the ESP32S3 Dev Module board and the correct COM port.
- Copy the code above and paste it into Arduino IDE.
- Upload the code by clicking the Upload button.
- Put the pump in water and plug in the 12V power adapter.
- Watch the pump: it should pump water for five seconds, stop for five seconds, and repeat.
- Tip: do not run the pump dry for a long time. Most small pumps use the water to cool down, and running dry can damage them.
Code Explanation
The comments inside the code above explain each line. In short, pinMode() makes GPIO17 an output in setup(). Then loop() writes HIGH (pump on) and LOW (pump off), with a 5000 ms delay() between them.
How to Control Pump with MOSFET Module
The relay version works, but it can only give the pump full power. Below, the MOSFET module takes over, so the ESP32 S3 Uno can also run the pump at a lower flow.
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
| MOSFET Module Pin | Connect To |
|---|---|
| PWM | ESP32 S3 Uno D9 (GPIO46) |
| GND | ESP32 S3 Uno GND |
| + | 12V adapter + (through DC power jack) and pump red (+) wire |
| LOAD | pump black (-) wire |
| − | 12V adapter − (through DC power jack) |
The pump motor is a coil, so add a 1N4007 or 1N5819 flyback diode across the pump wires, with the stripe (cathode) on the pump + side. This protects the module from voltage spikes.
※ NOTE THAT:
D9 (GPIO46) is a boot strapping pin. If uploading fails, remove the wire from D9, upload, then connect it again.
ESP32 S3 Uno Code
We use the code from the MOSFET module tutorial without any change. First the pump runs at full flow for 2 seconds and stops for 2 seconds. After that, its power climbs from 10% to 100% and falls back to 0% in 10% steps.
Detailed Instructions
- Get the board and Arduino IDE ready, as described in the relay Quick Steps.
- Wire the pump to the MOSFET module as in the diagram.
- Upload the code, put the pump in water, then plug in the 12V adapter.
- Open the Serial Monitor at 9600 baud.
- Look at the water coming out of the tube: the stream gets stronger, then weaker. At very low power, a small pump may stop moving water.
Tip: use the MOSFET module with DC pumps only, and give it a supply of at least about 6V. An AC pump must stay on the relay.
Video Tutorial
Watch the video below to see this ESP32 S3 Uno project step by step.
Challenge Yourself
Try these ideas once the basic pump works:
- Build an automatic plant watering system with the ESP32 S3 Uno, a soil moisture sensor, and a pump.
- Make an automatic water refill system with the ESP32 S3 Uno, a water level sensor, and a pump.
FAQ
Can I connect a 12V pump directly to the ESP32 S3 Uno?
No. An ESP32 S3 Uno pin gives only 3.3V and a few milliamps. A 12V pump needs much more voltage and current. Use a relay or a MOSFET module with a separate 12V power supply.
Can I power the relay module from the 3.3V pin of the ESP32 S3 Uno?
Most relay modules have a 5V coil, so power their VCC from the 5V pin. The IN pin can still take the 3.3V signal from the ESP32 S3 Uno on most modules. If your relay does not click, use a 3V relay module or a module with a transistor driver.
Can I control the pump speed with the ESP32 S3 Uno?
Not with a relay. A relay can only switch the pump fully on or off. To change the flow, use a PWM signal with analogWrite() and a MOSFET driver.
Why does my pump run when the code says LOW?
Some relay modules are active LOW. They turn on when the IN pin is LOW. In that case, swap HIGH and LOW in the code, or move the pump wire from the NO terminal to the NC terminal.
What if my project needs more pins than the Uno headers give?
The ESP32 S3 Uno has two extra rows of holes with more GPIOs. GPIO15 and GPIO16 are I/O, PWM and analog. GPIO45 and GPIO35 to GPIO42 are I/O and PWM. GPIO47 and GPIO48 are output only, with PWM. Solder pin headers to use them and write the GPIO number in code. For more pumps or relays, GPIO35 to GPIO42 are a good choice. For a soil moisture or water level sensor, use GPIO15 or GPIO16. Be careful with two things. First, GPIO47 and GPIO48 may run at 1.8V instead of 3.3V on some modules (especially ones with "V" in the name, like R8V or R16V), so 3.3V devices can be damaged or act strangely. Second, GPIO0, GPIO3 (D6), GPIO45 and GPIO46 (D9) are boot strapping pins, and a wrong connection can stop the board from booting or uploading code. Use the other extra pins first.
Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| No COM port in Arduino IDE | USB driver is missing or the cable is charge-only | Install the CP210x or CH340 driver, try a data USB cable, or hold BOOT while pressing RESET |
| Relay never clicks | Relay VCC or GND is not connected, or the relay needs 5V | Power the relay VCC from 5V and check the GND wire |
| Relay clicks but the pump does not run | The 12V adapter is not plugged in or the pump is on the NC terminal | Plug in the adapter and move the pump wire to the NO terminal |
| Pump works the opposite way to the code | The relay module is active LOW | Swap HIGH and LOW in the digitalWrite() lines |
| Pump runs but no water comes out | Air in the tube or the pump inlet is not under water | Put the pump fully in water and check that the tube is not bent |
| Board resets when the pump starts | Pump and board share a weak supply | Power the pump from its own 12V adapter and keep only the signal on the board |