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

Arduino-Controlled Solar-Powered Automated Watering System

Image of Arduino-Controlled Solar-Powered Automated Watering System

Circuit Documentation

Summary

This circuit is designed to control a water pump based on soil moisture and rain detection. It uses an Arduino Mega 2560 to read data from a humidity sensor (YL-69) and a rain sensor, and then controls a 12V water pump through a single-channel relay. The system is powered by a 12V 7Ah battery, which is charged by a solar panel through a solar charge controller. A step-down buck converter is used to regulate the voltage to the Arduino Mega 2560.

Component List

12v 7ah Battery

  • Description: A rechargeable battery that provides the main power source for the circuit.
  • Pins: 12v +, 12v -

Solar Charge Controller

  • Description: Manages the power flow from the solar panel to the battery and the load.
  • Pins: Solar Cell +, Solar Cell -, Battery +, Battery -, Load +, Load -

Arduino Mega 2560

  • Description: The microcontroller unit that processes sensor data and controls the relay.
  • Pins: Multiple digital and analog pins, power pins (IOREF, RESET, 3V3, 5V, GND, VIN, etc.)

Step down Buck Converter

  • Description: Reduces the voltage from the solar charge controller to a level suitable for the Arduino.
  • Pins: IN +, IN - GND, OUT +, OUT - GND

Solar Panel

  • Description: Converts sunlight into electrical energy to charge the battery.
  • Pins: gnd, vcc

12V Single Channel Relay

  • Description: Acts as an electrically operated switch to control the water pump.
  • Pins: NC, COM, NO, IN, GND, VCC

Water Pump

  • Description: Pumps water when activated by the relay.
  • Pins: VCC, GND

Rain Sensor

  • Description: Detects rainwater and provides input to the Arduino.
  • Pins: AO, DO, GRD, VCC

Humidity Sensor (YL-69)

  • Description: Measures the soil moisture level and provides input to the Arduino.
  • Pins: A0, D0, GND, VCC

Wiring Details

12v 7ah Battery

  • 12v +: Connected to the Solar Charge Controller Battery + and the Relay NO pin.
  • 12v -: Connected to the Solar Charge Controller Battery -.

Solar Charge Controller

  • Solar Cell +: Connected to the Solar Panel vcc.
  • Solar Cell -: Connected to the Solar Panel gnd.
  • Battery +: Connected to the 12v 7ah Battery 12v + and the Relay NO pin.
  • Battery -: Connected to the 12v 7ah Battery 12v -.
  • Load +: Connected to the Step down Buck Converter IN +.
  • Load -: Connected to the Step down Buck Converter IN - GND.

Arduino Mega 2560

  • 5V: Connected to the Step down Buck Converter OUT +.
  • GND: Connected to the Step down Buck Converter OUT - GND and the Relay GND pin.
  • VIN: Connected to the Step down Buck Converter OUT +.
  • A0: Connected to the Humidity Sensor A0 pin.
  • D2 PWM: Connected to the Rain Sensor AO pin.
  • D13 PWM: Connected to the Relay IN pin.

Step down Buck Converter

  • IN +: Connected to the Solar Charge Controller Load +.
  • IN - GND: Connected to the Solar Charge Controller Load -.
  • OUT +: Connected to the Arduino Mega 2560 5V and VIN pins, and the Relay VCC pin.
  • OUT - GND: Connected to the Arduino Mega 2560 GND pin and the Relay GND pin.

Solar Panel

  • gnd: Connected to the Solar Charge Controller Solar Cell -.
  • vcc: Connected to the Solar Charge Controller Solar Cell +.

12V Single Channel Relay

  • NC: Not connected.
  • COM: Connected to the Water Pump VCC.
  • NO: Connected to the 12v 7ah Battery 12v +.
  • IN: Connected to the Arduino Mega 2560 D13 PWM pin.
  • GND: Connected to the Arduino Mega 2560 GND pin and the Step down Buck Converter OUT - GND.
  • VCC: Connected to the Step down Buck Converter OUT +.

Water Pump

  • VCC: Connected to the Relay COM pin.
  • GND: Not connected.

Rain Sensor

  • AO: Connected to the Arduino Mega 2560 D2 PWM pin.
  • DO: Not connected.
  • GRD: Connected to the Humidity Sensor GND pin.
  • VCC: Connected to the Humidity Sensor VCC pin.

Humidity Sensor (YL-69)

  • A0: Connected to the Arduino Mega 2560 A0 pin.
  • D0: Not connected.
  • GND: Connected to the Rain Sensor GRD pin.
  • VCC: Connected to the Rain Sensor VCC pin.

Documented Code

int moiSensorPin = A0;
int rainSensorPin = 2;
int pump = 13;

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

void loop() {
    int moiSensorData = analogRead(moiSensorPin);
    Serial.print(moiSensorData);
    int rainData = digitalRead(rainSensorPin);
    Serial.print(rainData);
    
    if (moiSensorData > 950) {
        Serial.println("soil is dry");
        if (rainData < 400) {
            digitalWrite(pump, LOW);
        }
        digitalWrite(pump, HIGH);
    } else if (moiSensorData >= 400 && moiSensorData <= 950) {
        Serial.println("mois medium");
    } else if (moiSensorData < 400) {
        digitalWrite(pump, LOW);
        Serial.println("soil is wet, water pump off");
    }
}

This code snippet is responsible for reading the moisture level from the humidity sensor and the rain detection from the rain sensor. It then controls the water pump through the relay based on the soil moisture and rain conditions. The pump is turned on when the soil is dry and there is no rain detected. The serial prints are used for debugging purposes to monitor sensor readings.