Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO-Based Automatic Plant Irrigation System with Soil Moisture and Water Level Sensors

Image of Arduino UNO-Based Automatic Plant Irrigation System with Soil Moisture and Water Level Sensors

Automatic Plant Irrigation System Documentation

Summary

This document details the design and implementation of an Automatic Plant Irrigation System. The system uses an Arduino UNO microcontroller to monitor soil moisture levels and control a water pump. The system includes a soil moisture sensor, a water level sensor, a buzzer module, and a micro servo. The Arduino UNO reads sensor data and activates the water pump when necessary.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. SparkFun Soil Moisture Sensor

    • Description: A sensor used to measure the moisture level in the soil.
    • Pins: VCC, GND, SIG
  3. 9V Battery

    • Description: A power source for the circuit.
    • Pins: -, +
  4. Water Level Sensor

    • Description: A sensor used to measure the water level.
    • Pins: SIG, VCC, GND
  5. Buzzer Module

    • Description: A module that produces sound when activated.
    • Pins: GND, Vcc, I/O
  6. Micro Servo 9G

    • Description: A small servo motor used for various control applications.
    • Pins: GND, +5V, PWM

Wiring Details

Arduino UNO

  • 5V connected to:

    • SparkFun Soil Moisture Sensor (VCC)
    • Buzzer Module (Vcc)
    • Water Level Sensor (VCC)
    • Micro Servo 9G (+5V)
  • GND connected to:

    • Buzzer Module (GND)
    • Water Level Sensor (GND)
    • Micro Servo 9G (GND)
    • SparkFun Soil Moisture Sensor (GND)
  • A0 connected to:

    • Water Level Sensor (SIG)
  • A1 connected to:

    • SparkFun Soil Moisture Sensor (SIG)
  • D9 connected to:

    • Micro Servo 9G (PWM)
  • D7 connected to:

    • Buzzer Module (I/O)

SparkFun Soil Moisture Sensor

  • VCC connected to:

    • Arduino UNO (5V)
  • GND connected to:

    • Arduino UNO (GND)
  • SIG connected to:

    • Arduino UNO (A1)

9V Battery

  • -: Not connected in the provided net list.
  • +: Not connected in the provided net list.

Water Level Sensor

  • SIG connected to:

    • Arduino UNO (A0)
  • VCC connected to:

    • Arduino UNO (5V)
  • GND connected to:

    • Arduino UNO (GND)

Buzzer Module

  • GND connected to:

    • Arduino UNO (GND)
  • Vcc connected to:

    • Arduino UNO (5V)
  • I/O connected to:

    • Arduino UNO (D7)

Micro Servo 9G

  • GND connected to:

    • Arduino UNO (GND)
  • +5V connected to:

    • Arduino UNO (5V)
  • PWM connected to:

    • Arduino UNO (D9)

Code Documentation

/*
 * Automatic Plant Irrigation System
 *
 * This Arduino sketch controls an automatic plant irrigation system. It uses a
 * rain/snow sensor to detect moisture and a soil moisture sensor to monitor the
 * soil's moisture level. If the soil is dry and it is not raining, the system
 * activates a water pump via a relay to water the plants.
 */

// Pin definitions
const int rainSensorPin = 6; // Digital pin connected to rain sensor
const int soilMoisturePin = A0; // Analog pin connected to soil moisture sensor
const int relayPin = 3; // Digital pin connected to relay

// Soil moisture threshold
const int soilMoistureThreshold = 500;

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Initialize pin modes
  pinMode(rainSensorPin, INPUT);
  pinMode(soilMoisturePin, INPUT);
  pinMode(relayPin, OUTPUT);

  // Ensure the relay is off initially
  digitalWrite(relayPin, LOW);
}

void loop() {
  // Read the rain sensor value
  int rainSensorValue = digitalRead(rainSensorPin);
  // Read the soil moisture sensor value
  int soilMoistureValue = analogRead(soilMoisturePin);

  // Print sensor values to the serial monitor
  Serial.print("Rain Sensor: ");
  Serial.print(rainSensorValue);
  Serial.print("\tSoil Moisture: ");
  Serial.println(soilMoistureValue);

  // Check if it is not raining and the soil is dry
  if (rainSensorValue == LOW && soilMoistureValue < soilMoistureThreshold) {
    // Turn on the relay to activate the water pump
    digitalWrite(relayPin, HIGH);
  } else {
    // Turn off the relay to deactivate the water pump
    digitalWrite(relayPin, LOW);
  }

  // Wait for a second before the next loop
  delay(1000);
}

This code initializes the necessary pins and continuously monitors the rain sensor and soil moisture sensor. If the soil is dry and it is not raining, the relay is activated to turn on the water pump. The sensor values are also printed to the serial monitor for debugging purposes.