An automatic plant watering system using an Arduino and moisture sensors is a great way to keep your plants healthy and happy while you're away. This DIY IoT project isn't too difficult to build and can be customized to fit your needs. In this comprehensive guide, I'll walk you through every step of constructing your own automated plant watering contraption.
Overview of the System
The main components of the automatic plant watering system are:
-
Arduino Uno - The microcontroller board that controls the system.
-
Moisture sensors - Detects moisture levels in the soil.
-
Water pump - Waters the plants when the soil moisture is low.
-
Power supply - Provides power to the Arduino and pump.
-
Tubing - Transports water from the pump to the plants.
-
Relay - Allows the Arduino to control the higher-voltage pump.
-
Wires - Connects the components together.
The Arduino gets data from the moisture sensors inserted into the soil. If the soil becomes too dry, the Arduino activates the water pump via the relay. Water flows through the tubing to the thirsty plants.
Parts and Tools Needed
You'll need the following parts:
- Arduino Uno board
- DFRobot moisture sensor module
- Submersible water pump with tubing
- 5V power supply
- Relay module
- Jumper wires
- Breadboard
- 9V battery connector (for powering Arduino)
And these tools:
- Wire strippers
- Wire cutters
- Soldering iron
Step 1 - Install Moisture Sensor
The first step is to set up the moisture sensors.
Moisture sensors measure the volumetric water content in soil. We'll insert probes into the soil near the plants we want to monitor.
I'm using a DFRobot moisture sensor module that has both analog and digital output. We only need to connect the analog output to the Arduino.
First, I inserted the moisture sensor's probes into the soil of my basil plant. The probes should be completely covered.
Be careful not to bury it too deep or you may damage the roots of your plants. Place it a few inches into the soil near the stem of the plant.
Step 2 - Assemble Circuit on Breadboard
Next, we need to assemble the circuit on a breadboard.
Here is a diagram of how everything needs to be connected:
The moisture sensor connects to the Arduino's analog input A0.
The relay module allows the Arduino to switch the water pump on and off. The pump gets its power separately from the 5V power supply.
Upload a simple sketch to the Arduino to test reading data from the moisture sensor. The analog value can range from 0-1023, with lower numbers being drier soil.
Step 3 - Connect Water Pump
The main actor in our automated plant watering system is the water pump. This pumps water from a reservoir to thirsty plants when directed by the Arduino.
Submersible fountain or aquarium pumps are good options. Just make sure it has enough power to transport water where you need it.
I'm using a simple 70 GPH submersible pump. I attached some 1/4" drip irrigation tubing to the output. This narrow tubing lets me easily direct water right to the base of my plants.
Connect the pump's power cables to the relay module on the breadboard circuit. The pump turns on when the relay is activated by the Arduino.
Test it out by powering up the Arduino and pump and toggling the relay with your code. Water should be pumped through the tubing!
Step 4 - Upload Control Code to the Arduino
Now for the programming. We need to add custom code to the Arduino to control the system.
This code reads the moisture sensor, decides when to water, and toggles the pump relay on and off.
Basically, it will:
- Read moisture level
- If too dry, turn water pump on
- If wet enough, turn pump off
And repeats!
Here is basic Arduino code to accomplish this:
```c++
const int moisturePin = A0; // Soil moisture sensor on Analog 0
const int pumpPin = 8; // Relay on Digital Pin 8
void setup() {
pinMode(pumpPin, OUTPUT); // Set pump as OUTPUT
}
void loop() {
int moistureValue = analogRead(moisturePin); // Get moisture value
if(moistureValue <= 400) { // If too dry
digitalWrite(pumpPin, HIGH); // Turn pump ON
} else {
digitalWrite(pumpPin, LOW); // Turn pump OFF
}
delay(1000); // Wait 1 second
}
```
The magic happens in the loop! It constantly checks the moisture sensor and switches the pump based on a threshold value.
You may need to tweak the moisture threshold for your sensors and plants. Just adjust the value in the IF statement.
Upload this sketch to your Arduino board and verify the system works end-to-end automatically!
Customizing Your System
That covers the basics of constructing an automated Arduino-based plant watering system. But there are plenty of ways to enhance or customize it:
-
Add more moisture sensors for large or multiple plants.
-
Use a relay board to control multiple water pumps.
-
Connect a flow sensor to measure and log how much water is dispensed.
-
Add an LCD screen and buttons to adjust settings.
-
Use a WiFi module like the ESP8266 to remotely monitor status.
-
Create an app to control the system from your smartphone.
So get creative! The Arduino platform is very flexible.
Conclusion
Building your own automatic plant watering system is a super fun and useful Arduino project. The complete watering bot can be constructed with about $50 worth of components and a weekend of tinkering.
The end result is plants that are happily watered just the right amount while you're on vacation. No more coming home to a jungle of wilted, thirsty greenery!
I hope this guide gives you a good blueprint for creating your own custom automated watering contraption. Let me know if you have any other questions as you build. Happy growing!