ESP32 - Control Pump
In this tutorial, we are going to learn how to control a pump using ESP32. Based on this tutorial, you can make the irrigation system, aquarium, water refilling system ...
|1||×||ESP-WROOM-32 Dev Module|
|1||×||Micro USB Cable|
|1||×||12V Power Adapter|
About 12V Pump
12V Pump usually has two pins:
- Negative (-) pin (black) needs to be connected to GND of DC power supply
- Positive (+) pin (red) needs to be connected to 12V of DC power supply
How to Control Pump
If 12V pump is powered by 12V power supply, it works. To control a pump, we need to use a relay in between ESP32 and pump. ESP32 can control the pump via the relay. If you do not have knowledge of relay (pinout, how they work, how to connect them to ESP32, how to program for them...), learn about relay in the ESP32 - Relay tutorial
Image is developed using Fritzing. Click to enlarge image
The below code repeatedly turns the pump ON in five seconds and OFF in five seconds,
- If this is the first time you use ESP32, see how to setup environment for ESP32 on Arduino IDE
- Connect the ESP32 board to your PC via a micro USB cable
- Open Arduino IDE, select the right ESP32 board and COM port
- Copy the above code and paste it to Arduino IDE
- Click Upload button on Arduino IDE to compile and upload code to ESP32 board
- See the pump's state
Read the line-by-line explanation in comment lines of code!
We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.
- Make an automatic irrigation system using ESP32, soil moisture sensor, and pump
- Make an automatic water refilling system using ESP32, water level sensor, and pump
※ NOTE THAT:
Note that this tutorial is incomplete. We will post on our Facebook Page when the tutorial is complete. Like it to get updated.