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

GSM-Based Automated Irrigation System with Moisture Sensing and Water Level Monitoring

View and Edit Project In Cirkit DesignerImage of GSM-Based Automated Irrigation System with Moisture Sensing and Water Level Monitoring

Circuit Documentation

Summary

The circuit is designed to monitor and control an irrigation system using an Arduino UNO as the central processing unit. It features a GSM module for remote communication, a humidity sensor for soil moisture measurement, an ultrasonic sensor for water tank level detection, a relay to control a water pump, an LCD display for real-time status updates, and a buzzer for audio alerts. The system is powered by two DC power sources, with step-down buck converters to regulate the voltage. The Arduino UNO is programmed to read sensor data, control the pump via the relay, display information on the LCD, and communicate with a user via SMS using the GSM module.

Component List

Wiring Details

2.1mm DC Barrel Jack

1-Channel Relay (5V 10A)

Humidity YL-69

Arduino UNO

LCD I2C Display

SIM 800L V2.0 GSM

Buzzer

Step down Buck Converter

HC-SR04 Ultrasonic Sensor

Water Pump

DC Power Source

Documented Code

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

// Pin definitions
const int moistureSensorPin = A0;
const int relayPin = 8;
const int buzzerPin = 10;
const int trigPin = 6;  // Ensure these are connected
const int echoPin = 5;  // Ensure these are connected
const int gsmTxPin = 4;
const int gsmRxPin = 3;

// LCD setup
LiquidCrystal_I2C lcd(0x26, 16, 2);  // Verify the correct address

// GSM setup
SoftwareSerial gsmSerial(gsmTxPin, gsmRxPin);
String incomingSMS;

// Flag to track if a low tank level message has been sent
bool lowTankMessageSent = false;

// Flag to track if a low moisture level message has been sent
bool lowMoistureMessageSent = false;

void beepBuzzer(int duration) {
  digitalWrite(buzzerPin, HIGH);
  delay(duration);
  digitalWrite(buzzerPin, LOW);
}

void waitForGSMNetwork() {
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Waiting for GSM");
  lcd.setCursor(0, 1);
  lcd.print("network...");

  while (true) {
    gsmSerial.println("AT+CREG?");
    delay(1000);

    if (gsmSerial.available()) {
      String response = gsmSerial.readString();
      if (response.indexOf("+CREG: 0,1") >= 0 || response.indexOf("+CREG: 0,5") >= 0) {
        lcd.init();
        lcd.backlight();
        lcd.setCursor(0, 0);
        lcd.print("GSM Network");
        lcd.setCursor(0, 1);
        lcd.print("Connected");
        delay(2000);
        lcd.clear();
        break;
      }
    }
  }
}

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
  gsmSerial.begin(9600);

  waitForGSMNetwork();

  // Initialize LCD
  lcd.init();
  lcd.backlight();
  lcd.clear();

  // Initialize pins
  pinMode(moistureSensorPin, INPUT);
  pinMode(relayPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  digitalWrite(relayPin, HIGH);

  // Beep buzzer to indicate system start
  beepBuzzer(100);
  delay(100);
  beepBuzzer(400);

  lcd.setCursor(0, 0);
  lcd.print("Mark Kasaine");
  lcd.setCursor(0, 1);
  lcd.print("WELCOME!! ");
  delay(1000);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("GSM BASED");
  lcd.setCursor(0, 1);
  lcd.print("IRRIGATION SYTM");
  delay(1000);
  lcd.clear();

  // Initialize GSM module
  delay(1000);
  gsmSerial.println("AT");
  delay(1000);
  gsmSerial.println("AT+CMGF=1");  // Set SMS to text mode
  delay(1000);
  gsmSerial.println("AT+CNMI=1,2,0,0,0");  // Configure module to send SMS data to serial out
  delay(1000);
}

void loop() {
  // Read moisture level
  int moistureLevel = analogRead(moistureSensorPin);
  int moisturePercentage = map(mo