Automated Plant Watering System Using Arduino: A Step-by-Step Guide

  • calendar_today  May, 22 2023
  • visibility  662

Building an automated plant watering system can seem like a daunting task, but with the right tools and instructions, it can be a great project for beginners and experts alike. Using an Arduino UNO R3 board, a level detection module, a 5V relay, and a servo motor, this guide will take you through the steps to create an effective plant watering system.

Step 1: Gather Your Components For this project, you will need the following components:

  • Arduino UNO R3 board
  • Large breadboard
  • 5V Relay
  • Level detection module
  • Servo motor
  • Breadboard jumper wires
  • 9-volt battery snap

Step 2: Wiring Connect your components as follows:

Level Detection Module to Arduino UNO:

  • VCC to 5V
  • GND to GND
  • OUT to Digital Pin 2

Relay Module to Arduino UNO:

  • VCC to 5V
  • GND to GND
  • IN1 to Digital Pin 3

Servo Motor to Arduino UNO:

  • VCC (usually red wire) to 5V
  • GND (usually black or brown wire) to GND
  • Signal wire (usually orange or yellow) to Digital Pin 9

Relay to Servo Motor (via water pump): The Relay should control the power to the water pump, which is operated by the servo motor. Wire the circuit so that the normally open (NO) terminal of the relay is in series with the power line (5V) of the servo motor. Connect the COM terminal of the relay to the power line (VCC) of the servo motor.

Step 3: Coding Once your components are connected correctly, it's time to write and upload the Arduino code. This code will control the operation of the water pump based on the readings from the water level sensor.

After your code is uploaded, your Arduino Automated Plant Watering System should be operational. Now you can have peace of mind knowing your plants will be watered even when you're busy or away.


Step 4: Arduino IDE Code

To automate your plant watering system, you'll need to write a program that can interact with the hardware you've set up. Here's a simple Arduino code that should do the trick:

#include <Servo.h>


// Level detection module connected to pin 2

#define LEVEL_PIN 2


// Relay module connected to pin 3

#define RELAY_PIN 3


// Servo on pin 9

#define SERVO_PIN 9


// Servo object

Servo myservo;


void setup() {

  pinMode(LEVEL_PIN, INPUT);

  pinMode(RELAY_PIN, OUTPUT);


  myservo.attach(SERVO_PIN);


  // Start with relay off (pump off)

  digitalWrite(RELAY_PIN, LOW);

}


void loop() {

  int level = digitalRead(LEVEL_PIN);

  

  // If the water level is low

  if (level == LOW) {

    // Turn on relay (pump on)

    digitalWrite(RELAY_PIN, HIGH);

    

    // Make servo rotate to a position that opens the water pump

    myservo.write(90);

  } 

  else {

    // Turn off relay (pump off)

    digitalWrite(RELAY_PIN, LOW);

    

    // Make servo rotate back to a position that closes the water pump

    myservo.write(0);

  }

}


In the Arduino IDE, create a new sketch and paste the above code into the editor. Save your sketch, then click the "Upload" button to transfer your code to the Arduino UNO. The code monitors the output from the water level sensor and operates the relay (and therefore the water pump) based on the water level.

This code is relatively simple, operating the water pump based on a single threshold level. If you wish to have more control, you could use an analog water level sensor and implement multiple thresholds.

Once the code has been successfully uploaded to the Arduino, your automated plant watering system should be ready for action! Always remember to disconnect the power when making adjustments to your setup.

That's it! You've now successfully built an automated plant watering system using Arduino. This is an excellent project for both beginners and seasoned Arduino enthusiasts. It incorporates a variety of elements, such as sensors, actuators, and automation, making it an ideal project to hone your skills while creating something practical and useful. Happy tinkering!