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

Arduino UNO Based Automated Irrigation System with GSM Control

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Automated Irrigation System with GSM Control

Circuit Documentation

Summary

The circuit is designed to control a 220V fan using various sensors and modules, including a SIM800L GSM module for communication, a DHT11 sensor for temperature and humidity readings, a rain sensor, a soil moisture sensor, and an LCD I2C display for output. The fan is controlled via a 1-Channel Relay, which is operated by the Arduino UNO based on sensor inputs or GSM commands. The system is powered by a 9V battery.

Component List

SIM 800L V2.0 GSM Module

Arduino UNO

1-Channel Relay (5V 10A)

9V Battery

Soil Moisture Sensor

RS485 Module

DHT11 Sensor

Rain Sensor

LCD I2C Display

Water Pump

Wiring Details

SIM 800L V2.0 GSM Module

Arduino UNO

1-Channel Relay (5V 10A)

9V Battery

Soil Moisture Sensor

RS485 Module

DHT11 Sensor

Rain Sensor

LCD I2C Display

Water Pump

Documented Code

/*
 * Arduino Sketch to control a 220V fan using a 1-Channel Relay, SIM800L GSM module,
 * DHT11 sensor, Rain Sensor, Soil Moisture Sensor, and LCD I2C Display.
 * The fan is controlled via a relay connected to pin D2 of the Arduino.
 * The SIM800L module is used for GSM communication and is connected to pins D0 and D1.
 * The fan will be turned on or off based on commands received via GSM or sensor readings.
 * The LCD displays temperature, humidity, and fan status.
 */

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

// Pin definitions
const int relayPin = 2; // Relay control pin
const int simTxPin = 1; // SIM800L TX pin
const int simRxPin = 0; // SIM800L RX pin
const int dhtPin = 7; // DHT11 data pin
const int rainAnalogPin = A0; // Rain sensor analog pin
const int rainDigitalPin = 8; // Rain sensor digital pin
const int soilMoisturePin = 3; // Soil moisture sensor pin

// Create a SoftwareSerial object for SIM800L communication
SoftwareSerial sim800l(simRxPin, simTxPin);

// Create a DHT object
DHT dht(dhtPin, DHT11);

// Create an LCD object
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  // Initialize relay pin as output
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, LOW); // Ensure fan is off initially

  // Initialize serial communication for debugging
  Serial.begin(9600);

  // Initialize SIM800L communication
  sim800l.begin(9600);
  Serial.println("SIM800L initialized.");

  // Initialize DHT11 sensor
  dht.begin();

  // Initialize LCD
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Initializing...");
}

void loop() {
  // Read temperature and humidity from DHT11
  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();

  // Read rain sensor values
  int rainAnalogValue = analogRead(rainAnalogPin);
  int rainDigitalValue = digitalRead(rainDigitalPin);

  // Read soil moisture sensor value
  int soilMoistureValue = analogRead(soilMoisturePin);

  // Check for incoming messages from SIM800L
  if (sim800l.available()) {
    String message = sim800l.readString();
    Serial.println("Message received: " + message);

    // Check for fan control commands
    if (message.indexOf("FAN ON") >= 0) {
      digitalWrite(relayPin, HIGH); // Turn fan on
      Serial.println("Fan turned ON.");
    } else if (message.indexOf("FAN OFF") >= 0) {
      digitalWrite(relayPin, LOW); // Turn fan off
      Serial.println("Fan turned OFF.");
    }
  }

  // Control fan based on sensor readings
  if (rainDigitalValue == LOW || soilMoistureValue > 500) {
    digitalWrite(relayPin, LOW); // Turn fan off
  }

  // Update LCD display
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(temperature);
  lcd.print("C");
  lcd.setCursor(0, 1);
  lcd.print("Humidity: ");
  lcd.print(humidity);
  lcd.print("%");
  lcd.setCursor(0, 2);
  lcd.print("Fan: ");
  lcd.print(digitalRead(relayPin) == HIGH ? "ON" : "OFF");

  // Add a small delay to avoid overwhelming the serial buffer
  delay(1000);
}

This code is responsible for reading sensor data, controlling the relay based on sensor inputs or GSM commands, and updating the LCD display with the current temperature, humidity, and fan status. The SoftwareSerial library is used for communication with the SIM800L GSM module, and the LiquidCrystal_I2C library is used for the LCD display. The DHT library is used to interface with the DHT11 sensor.