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

Arduino UNO Smart Irrigation System with DHT11, Water Level, and Soil Moisture Sensors

View and Edit Project In Cirkit DesignerImage of Arduino UNO Smart Irrigation System with DHT11, Water Level, and Soil Moisture Sensors

Circuit Documentation

Summary

This circuit is designed to control a water pump, light, and fan using relays based on input from a DHT11 sensor, water level sensor, and a capacitive soil moisture sensor. The status of the system is displayed on a 20x4 I2C LCD panel. The Arduino UNO microcontroller is used to process the sensor data and control the relays.

Component List

  1. DHT11 Sensor V2

    • Description: Temperature and humidity sensor.
    • Pins: GND, DAT, VCC
  2. Fan

    • Description: Cooling fan.
    • Pins: GND, 5V
  3. 5V Battery

    • Description: Power source.
    • Pins: Positive, Negative
  4. 5V Relay

    • Description: Relay module for switching devices.
    • Pins: Normally Open, Common Terminal, Normally Closed, In, GND, VCC
  5. Water Level Sensor

    • Description: Sensor to detect water level.
    • Pins: SIG, VCC, GND
  6. Capacitive Soil Moisture Sensor V1.2

    • Description: Sensor to measure soil moisture.
    • Pins: GND, VCC, AOUT
  7. 12V Power Supply

    • Description: Power source.
    • Pins: +, -
  8. Water Pump

    • Description: Pump for water circulation.
    • Pins: VCC, GND
  9. 12V White LED Strip

    • Description: LED strip for lighting.
    • Pins: +12V, GND
  10. Arduino UNO

    • Description: Microcontroller for processing and control.
    • 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
  11. 20x4 I2C LCD Panel

    • Description: Display panel for showing status.
    • Pins: GND, VCC, SDA, SCL

Wiring Details

DHT11 Sensor V2

Fan

5V Battery

5V Relay

Water Level Sensor

Capacitive Soil Moisture Sensor V1.2

12V Power Supply

Water Pump

12V White LED Strip

Arduino UNO

20x4 I2C LCD Panel

Code Documentation

/*
 * Arduino Sketch for controlling a pump, light, and fan using relays
 * based on input from a DHT11 sensor, water level sensor, and a capacitive
 * soil moisture sensor. The status is displayed on a 20x4 I2C LCD panel.
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#include <TimeLib.h>

// Pin definitions
#define DHTPIN 7
#define DHTTYPE DHT11
#define RELAY_PUMP A3
#define RELAY_LIGHT A5
#define RELAY_FAN A4
#define WATER_SENSOR_PIN A1
#define SOIL_SENSOR_PIN A2

// Initialize sensors and display
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup() {
  Serial.begin(9600);
  dht.begin();
  lcd.init();
  lcd.backlight();
  pinMode(RELAY_PUMP, OUTPUT);
  pinMode(RELAY_LIGHT, OUTPUT);
  pinMode(RELAY_FAN, OUTPUT);
  digitalWrite(RELAY_PUMP, LOW);
  digitalWrite(RELAY_LIGHT, LOW);
  digitalWrite(RELAY_FAN, LOW);
  setTime(12, 0, 0, 1, 1, 2023);
}

void loop() {
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  int waterLevel = analogRead(WATER_SENSOR_PIN);
  int soilMoisture = analogRead(SOIL_SENSOR_PIN);

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Temp: "); lcd.print(t); lcd.print(" C");
  lcd.setCursor(0, 1);
  lcd.print("Humidity: "); lcd.print(h); lcd.print(" %");
  lcd.setCursor(0, 2);
  lcd.print("Water Level: "); lcd.print(waterLevel);
  lcd.setCursor(0, 3);
  lcd.print("Soil Moisture: "); lcd.print(soilMoisture);

  if (t > 25) {
    digitalWrite(RELAY_FAN, HIGH);
  } else {
    digitalWrite(RELAY_FAN, LOW);
  }
  if (h > 60 || waterLevel < 500 || soilMoisture < 300) {
    digitalWrite(RELAY_PUMP, HIGH);
  } else {
    digitalWrite(RELAY_PUMP, LOW);
  }
  if (hour() >= 18 || hour() < 6) {
    digitalWrite(RELAY_LIGHT, HIGH);
  } else {
    digitalWrite(RELAY_LIGHT, LOW);
  }
  delay(2000);
}

This code initializes the sensors and the LCD display, reads the sensor values, and controls the relays based on the sensor inputs. The status is displayed on the LCD panel, and the relays are activated or deactivated based on the conditions specified in the code.