Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino-Based Automated Water Sprinkling System with Soil Moisture and Rain Detection

View and Edit Project In Cirkit DesignerImage of Arduino-Based Automated Water Sprinkling System with Soil Moisture and Rain Detection

Automated Water Sprinkling System Documentation

Summary

This document details the design and implementation of an automated water sprinkling system. The system uses an Arduino UNO microcontroller to manage a relay module that controls a water pump. A soil moisture sensor is used to detect soil moisture levels, and an I2C LCD is used to display system status. The system is designed to water plants automatically based on soil moisture levels and prevent watering during rain.

Component List

  1. Arduino UNO

    • Description: 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. Relay module 5v-30v

    • Description: Relay module used to control high voltage devices.
    • Pins: common contact, normally open, normally closed, trigger, V-, V+
  3. Water pump

    • Description: Pump used to water plants.
    • Pins: positive, negative
  4. SparkFun Soil Moisture Sensor

    • Description: Sensor used to measure soil moisture levels.
    • Pins: VCC, GND, SIG
  5. 16x2 I2C LCD

    • Description: LCD display with I2C interface.
    • Pins: GND, VCC, SDA, SCL
  6. LM393

    • Description: Comparator module used for rain detection.
    • Pins: A0, D0, GND, VCC

Wiring Details

Arduino UNO

Relay module 5v-30v

Water pump

SparkFun Soil Moisture Sensor

16x2 I2C LCD

LM393

Code Documentation

/*
 * Automated Water Sprinkling System
 * This code manages an automated water sprinkling system based on time and
 * soil moisture level detection. The system uses a relay to control a water
 * pump, a soil moisture sensor to detect soil moisture levels, and a rain
 * sensor to prevent watering during rain.
 */

const int relayPin = 3; // Relay module trigger pin
const int rainSensorPin = 6; // Rain sensor digital output pin
const int soilMoisturePin = A0; // Soil moisture sensor analog output pin

void setup() {
  pinMode(relayPin, OUTPUT);
  pinMode(rainSensorPin, INPUT);
  Serial.begin(9600);
}

void loop() {
  int soilMoistureValue = analogRead(soilMoisturePin);
  int rainSensorValue = digitalRead(rainSensorPin);

  Serial.print("Soil Moisture: ");
  Serial.println(soilMoistureValue);
  Serial.print("Rain Sensor: ");
  Serial.println(rainSensorValue);

  if (rainSensorValue == LOW && soilMoistureValue < 300) {
    digitalWrite(relayPin, HIGH); // Turn on water pump
  } else {
    digitalWrite(relayPin, LOW); // Turn off water pump
  }

  delay(60000); // Wait for 1 minute before next check
}

This code initializes the pins for the relay, rain sensor, and soil moisture sensor. In the loop function, it reads the soil moisture and rain sensor values, prints them to the serial monitor, and controls the relay to turn the water pump on or off based on the sensor readings. The system checks the sensor values every minute.