Arduino - Soil Moisture Sensor Pump
In this tutorial, We are going to learn how to use the Arduino and capacitive soil moisture sensor to control the pump.
Hardware Required
Or you can buy the following sensor kits:
1 | × | DIYables Sensor Kit (30 sensors/displays) | |
1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some links direct to products from our own brand, DIYables.
About soil moisture sensor and Pump
If you do not know about pump and soil moisture sensor (pinout, how it works, how to program ...), learn about them in the following tutorials:
- Arduino - Soil Moisture Sensor tutorial
- Arduino - Controls Pump tutorial
How It Works
Arduino periodically reads the value from the capacitive soil moisture sensor. Based on the soil moisture value, it will take the following actions:
- If the soil moisture value is below a threshold, Arduino automatically activates a relay to turn a pump on.
- Otherwise, Arduino automatically deactivates a relay to turn a pump off.
Wiring Diagram
This image is created using Fritzing. Click to enlarge image
Arduino Code
Quick Steps
- Do calibration to determine the wet-dry THRESHOLD, see Arduino - Calibrates Soil Moisture Sensor
- Update the calibrated value to THRESHOLD in the code
- Open Serial Monitor on Arduino IDE
- Upload the code to Arduino
- Check out the result on Serial Monitor.
Code Explanation
Read the line-by-line explanation in the comment lines of the source code!
Video Tutorial
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.