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

Arduino Mega 2560 Smart Irrigation System with Rain/Snow Sensor and Battery-Powered Water Pump

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560 Smart Irrigation System with Rain/Snow Sensor and Battery-Powered Water Pump

Circuit Documentation

Summary

This circuit is designed to control a water pump based on the readings from a soil moisture sensor and a rain/snow sensor. The system uses an Arduino Mega 2560 microcontroller to read sensor data and control a relay, which in turn controls the water pump. The circuit is powered by a 18650 Li-Ion battery.

Component List

  1. Water Pump

    • Pins: VCC, GND
    • Description: A pump used to move water.
    • Purpose in Circuit: To provide water based on sensor readings.
  2. Arduino Mega 2560

    • Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, AREF, SDA, SCL
    • Description: A microcontroller board based on the ATmega2560.
    • Purpose in Circuit: To read sensor data and control the relay.
  3. Rain/Snow Sensor - Board

    • Pins: 1, 2, A0 (Analog), D0 (Digital), GND, VCC (5V)
    • Description: A sensor to detect rain or snow.
    • Purpose in Circuit: To provide environmental data to the microcontroller.
  4. 18650 Li-Ion

    • Pins: Positive, Negative
    • Description: A rechargeable lithium-ion battery.
    • Purpose in Circuit: To power the water pump and relay.
  5. Soil Moisture Sensor

    • Pins: Positive, Negative
    • Description: A sensor to measure soil moisture levels.
    • Purpose in Circuit: To provide soil moisture data to the microcontroller.
  6. Relay 12V

    • Pins: Ground, In, VCC, NO, COM, NC
    • Description: A relay module to control high-power devices.
    • Purpose in Circuit: To control the water pump based on microcontroller signals.

Wiring Details

Water Pump

Arduino Mega 2560

Rain/Snow Sensor - Board

18650 Li-Ion

Soil Moisture Sensor

Relay 12V

Documented Code

Arduino Mega 2560 Code

int water; //random variable 

void setup() {
  pinMode(3, OUTPUT); //output pin for relay board, this will send signal to the relay
  pinMode(6, INPUT); //input pin coming from soil sensor
}

void loop() { 
  water = digitalRead(6);  // reading the coming signal from the soil sensor
  if (water == HIGH) { // if water level is full then cut the relay 
    digitalWrite(3, LOW); // low is to cut the relay
  } else {
    digitalWrite(3, HIGH); //high to continue providing signal and water supply
  }
  delay(400); 
}

This code initializes the pins for the relay and soil sensor, reads the soil moisture level, and controls the relay to turn the water pump on or off based on the moisture level.