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

Arduino Mega 2560-Based Smart Agriculture System with GSM and Wi-Fi Connectivity

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560-Based Smart Agriculture System with GSM and Wi-Fi Connectivity

IoT-based Smart Agriculture System Documentation

Summary

This document provides a detailed overview of an IoT-based Smart Agriculture System. The system automates farm management by monitoring environmental conditions such as temperature and soil moisture and controlling irrigation using a water pump. It also sends alerts and updates via a GSM module, enhancing farm efficiency and sustainability with automated and remote monitoring.

Component List

  1. Temperature Sensor (LM35)

    • Description: Measures temperature.
    • Pins: +Vs, Vout, GND
  2. HC-SR501 PIR Motion Sensor

    • Description: Detects motion.
    • Pins: Output, Ground, Power Supply
  3. Capacitive Soil Moisture Sensor V1.2

    • Description: Measures soil moisture.
    • Pins: GND, VCC, AOUT
  4. LED: Two Pin (red)

    • Description: Indicates status.
    • Pins: Cathode, Anode
  5. Resistor (220 Ohms)

    • Description: Limits current.
    • Pins: Pin1, Pin2
  6. Resistor (10k Ohms)

    • Description: Limits current.
    • Pins: Pin1, Pin2
  7. Arduino Mega 2560

    • Description: Main microcontroller.
    • Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, AREF, SDA, SCL
  8. 5V Mini Water Pump

    • Description: Controls water flow.
    • Pins: Positive Pin, Negative Pin
  9. SIM900A

    • Description: GSM module for communication.
    • Pins: GND, DB9-3 (RXD), DB9-2 (TXD), 5V, 3VR, 5VR, 3VT, 5VT, VCC, Ring, RESTART, RESET, STATUS
  10. 12V Single Channel Relay

    • Description: Controls high voltage devices.
    • Pins: NC, COM, NO, IN, GND, VCC
  11. Buzzer

    • Description: Provides audible alerts.
    • Pins: Positive, Negative
  12. Lipo Battery 2200mAH 30c

    • Description: Power source.
    • Pins: VCC, GND
  13. ESP-8266 Controller

    • Description: Wi-Fi module for communication.
    • Pins: A0, RSV, SD3, SD5, SD1, CMD, D0-D8, RX, TX, Vin, 5V, 3V3, GND, CLK, RST, EN

Wiring Details

Temperature Sensor (LM35)

HC-SR501 PIR Motion Sensor

Capacitive Soil Moisture Sensor V1.2

LED: Two Pin (red)

Resistor (220 Ohms)

Resistor (10k Ohms)

Arduino Mega 2560

5V Mini Water Pump

SIM900A

12V Single Channel Relay

Buzzer

Lipo Battery 2200mAH 30c

ESP-8266 Controller

Documented Code

/*
 * IoT-based Smart Agriculture System
 * This Arduino sketch automates farm management by monitoring environmental
 * conditions (temperature, soil moisture) and controlling irrigation using a
 * water pump. The system sends alerts and updates via a GSM module, enhancing
 * farm efficiency and sustainability with automated and remote monitoring.
 */

// Pin definitions
const int soilMoisturePin = A0;
const int tempSensorPin = A1;
const int relayPin = 8;
const int buzzerPin = 9;
const int ledPin = 10;
const int pirSensorPin = 11;
const int gsmTxPin = 16;
const int gsmRxPin = 17;
const int espTxPin = 18;
const int espRxPin = 19;

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
  Serial1.begin(9600); // GSM module
  Serial2.begin(9600); // ESP8266

  // Initialize pins
  pinMode(soilMoisturePin, INPUT);
  pinMode(tempSensorPin, INPUT);
  pinMode(relayPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(pirSensorPin, INPUT);

  // Initial states
  digitalWrite(relayPin, LOW);
  digitalWrite(buzzerPin, LOW);
  digitalWrite(ledPin, LOW);
}

void loop() {
  // Read sensor values
  int soilMoisture = analogRead(soilMoisturePin);
  int tempValue = analogRead(tempSensorPin