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:

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:

And these tools:

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:

  1. Read moisture level
  2. If too dry, turn water pump on
  3. 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:

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!