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

Arduino UNO Based Smart Irrigation and Temperature Control System

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Smart Irrigation and Temperature Control System

Smart Irrigation and Temperature Control System Documentation

Summary

This document describes a Smart Irrigation and Temperature Control System designed to automate the watering process of plants based on soil moisture levels and to control the temperature by activating a fan when needed. The system uses an Arduino UNO as the central processing unit, interfacing with various sensors and actuators including a DHT11 temperature and humidity sensor, a capacitive soil moisture sensor, a 16x2 LCD for display, a 2-channel relay module to control a water pump and a fan, and a buzzer for alerts. The system is powered by a 5V battery for the relay and sensors, and a 9V battery for the fan.

Component List

16X2 LCD

2-Channel Relay

5V Mini Water Pump

DHT11

Arduino UNO

Buzzer

5V Battery

9V Battery

120mm Fan 12V

Capacitive Soil Moisture Sensor V1.2

Potentiometer

Wiring Details

16X2 LCD

2-Channel Relay

5V Mini Water Pump

DHT11

Arduino UNO

Buzzer

Capacitive Soil Moisture Sensor V1.2

Potentiometer

Documented Code

#include <DHT.h>
#include <LiquidCrystal.h>

// Definition of pins for sensors and relays
#define DHTPIN 7       // Pin for the DHT11 sensor
#define DHTTYPE DHT11  // Type of sensor used
#define FAN_PIN 1      // Pin for fan control
#define RELAY_PIN 0    // Pin for relay control (pump)
#define MOISTURE_SENSOR_PIN A0  // Analog pin for soil moisture sensor

// Thresholds
const int moistureThreshold = 500; // Threshold for soil moisture
const float tempThreshold = 35.0;  // Temperature threshold for activating the fan

// Initialization of objects
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

void setup() {
  // Initialize pins
  pinMode(FAN_PIN, OUTPUT);
  pinMode(RELAY_PIN, OUTPUT);
  pinMode(MOISTURE_SENSOR_PIN, INPUT);

  // Initialize serial monitor and LCD
  Serial.begin(9600);
  lcd.begin(16, 2);
  
  // Startup message
  Serial.println("Smart Irrigation and Temperature Control System");
  lcd.print("System Starting");
  delay(2000); // Wait for 2 seconds
  lcd.clear();

  // Initialize DHT sensor
  dht.begin();
}

void loop() {
  // Read soil moisture
  int moistureValue = analogRead(MOISTURE_SENSOR_PIN);

  // Read air humidity and temperature
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();

  // Check if sensor readings failed
  if (isnan(humidity) || isnan(temperature)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Control the pump based on soil moisture
  if (moistureValue < moistureThreshold) {
    digitalWrite(RELAY_PIN, HIGH);  // Turn on the pump
    lcd.setCursor(0, 1);  
    lcd.print("Irrigating    ");
  } else {
    digitalWrite(RELAY_PIN, LOW);   // Turn off the pump
    lcd.setCursor(0, 1);  
    lcd.print("Pump off     ");
  }

  // Control the fan based on temperature
  if (temperature > tempThreshold) {
    digitalWrite(FAN_PIN, HIGH);    // Turn on the fan
  } else {
    digitalWrite(FAN_PIN, LOW);     // Turn off the fan
  }

  // Display results on the LCD
  lcd.setCursor(0, 0);          
  lcd.print("Temp: ");
  lcd.print(temperature);
  lcd.print("C  ");
  lcd.setCursor(10, 0);         
  lcd.print("H: ");
  lcd.print(humidity);
  lcd.print("%  ");

  // Print soil moisture to the serial monitor
  Serial.print("Soil Moisture: ");
  Serial.print(moistureValue);
  Serial.print(" | Temp: ");
  Serial.print(temperature);
  Serial.print(" C | Humidity: ");
  Serial.print(humidity);
  Serial.println(" %");

  // Pause before the next reading
  delay(2000); 
}

This code is responsible for reading the soil moisture and air temperature and humidity, controlling the water pump and fan based on predefined thresholds, and displaying the status and sensor readings on the LCD and serial monitor.