Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino Nano-Based Landslide Detection System with GSM Alert

Image of Arduino Nano-Based Landslide Detection System with GSM Alert

Circuit Documentation

Summary

This circuit is designed to monitor environmental conditions that could indicate a potential landslide. It includes an Arduino Nano microcontroller interfaced with various sensors and modules, including a soil moisture sensor, a vibration sensor (SW-420), an accelerometer (ADXL345), and a GSM module (SIM800L) for sending SMS alerts. The circuit also features visual indicators (LEDs) and an audible alert (buzzer).

Component List

Arduino Nano

  • Microcontroller board based on the ATmega328P
  • Pins: D1/TX, D0/RX, RESET, GND, D2 to D13, VIN, 5V, A0 to A7, AREF, 3V3

SW-420 Vibration Sensor

  • Detects vibrations and movements
  • Pins: VCC, Ground, Digital output

Buzzer

  • Emits an audible alert when activated
  • Pins: PIN, GND

LEDs (Red, Yellow, Green)

  • Visual indicators of the circuit status
  • Pins: Cathode, Anode

SIM800L GSM Module

  • Provides GSM communication capabilities to send SMS alerts
  • Pins: 5V, GND, VDD, SIM_TXD, SIM_RXD, RST

Soil Moisture Sensor

  • Measures the moisture level in the soil
  • Pins: VCC, GND, SIG

ADXL345 Accelerometer (Keystudio)

  • Measures acceleration and tilt
  • Pins: 3.3V, SDA, SCL, GND, 5V

Resistors (220 Ohms)

  • Limits current to the LEDs
  • Pins: Pin1, Pin2

5V Battery

  • Power source for the GSM module
  • Pins: Positive, Negative

Wiring Details

Arduino Nano

  • GND connected to the common ground net
  • D2 connected to the Digital output of the SW-420 Vibration Sensor
  • D3 connected to the PIN of the Buzzer
  • D4, D5, D6 connected to the pin2 of the respective 220 Ohm Resistors for LED control
  • D7 (TX) and D8 (RX) connected to the SIM_RXD and SIM_TXD of the SIM800L GSM Module
  • 5V connected to the VCC of the SW-420 Vibration Sensor, Soil Moisture Sensor, and ADXL345
  • A4 (SDA) and A5 (SCL) connected to the SDA and SCL of the ADXL345
  • A0 connected to the SIG of the Soil Moisture Sensor

SW-420 Vibration Sensor

  • VCC connected to 5V of the Arduino Nano
  • Ground connected to the common ground net
  • Digital output connected to D2 of the Arduino Nano

Buzzer

  • PIN connected to D3 of the Arduino Nano
  • GND connected to the common ground net

LEDs (Red, Yellow, Green)

  • Cathode connected to the common ground net
  • Anode connected to pin1 of the respective 220 Ohm Resistors

SIM800L GSM Module

  • 5V connected to the Positive of the 5V Battery
  • GND connected to the Negative of the 5V Battery
  • SIM_RXD connected to D7 (TX) of the Arduino Nano
  • SIM_TXD connected to D8 (RX) of the Arduino Nano

Soil Moisture Sensor

  • VCC connected to 5V of the Arduino Nano
  • GND connected to the common ground net
  • SIG connected to A0 of the Arduino Nano

ADXL345 Accelerometer (Keystudio)

  • 5V connected to 5V of the Arduino Nano
  • SDA connected to A4 of the Arduino Nano
  • SCL connected to A5 of the Arduino Nano
  • GND connected to the common ground net

Resistors (220 Ohms)

  • Pin1 connected to the Anode of the respective LEDs
  • Pin2 connected to D4, D5, D6 of the Arduino Nano

5V Battery

  • Positive connected to 5V of the SIM800L GSM Module
  • Negative connected to GND of the SIM800L GSM Module

Documented Code

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>
#include <SoftwareSerial.h>

// Pin definitions
#define SOIL_SENSOR_PIN A0
#define VIBRATION_SENSOR_PIN 2
#define BUZZER_PIN 3
#define GREEN_LED 4
#define YELLOW_LED 5
#define RED_LED 6

// Threshold values
#define MOISTURE_THRESHOLD 500  // Soil moisture threshold
#define VIBRATION_THRESHOLD 100 // Vibration sensor threshold
#define TILT_THRESHOLD 15.0     // Tilt threshold (degrees)

// Initialize accelerometer
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);

// GSM module connected to pins D7 (TX) and D8 (RX)
SoftwareSerial gsm(7, 8);

void setup() {
  // Pin Modes
  pinMode(SOIL_SENSOR_PIN, INPUT);
  pinMode(VIBRATION_SENSOR_PIN, INPUT);
  pinMode(BUZZER_PIN, OUTPUT);
  pinMode(GREEN_LED, OUTPUT);
  pinMode(YELLOW_LED, OUTPUT);
  pinMode(RED_LED, OUTPUT);

  // Initialize Serial and GSM
  Serial.begin(9600);
  gsm.begin(9600);

  // Initialize Accelerometer
  if (!accel.begin()) {
    Serial.println("No ADXL345 detected, check wiring.");
    while (1);
  }
  accel.setRange(ADXL345_RANGE_16_G); // Set range for the accelerometer
}

void loop() {
  int moistureLevel = analogRead(SOIL_SENSOR_PIN);
  int vibration = digitalRead(VIBRATION_SENSOR_PIN);

  sensors_event_t event;
  accel.getEvent(&event);
  float tilt = atan2(event.acceleration.y, event.acceleration.x) * 180 / PI;

  // Print sensor readings
  Serial.print("Soil Moisture: ");
  Serial.println(moistureLevel);
  Serial.print("Vibration: ");
  Serial.println(vibration);
  Serial.print("Tilt: ");
  Serial.println(tilt);

  // Landslide detection logic
  if (moistureLevel > MOISTURE_THRESHOLD || vibration > VIBRATION_THRESHOLD || abs(tilt) > TILT_THRESHOLD) {
    // Trigger alert
    digitalWrite(BUZZER_PIN, HIGH);
    digitalWrite(RED_LED, HIGH);
    digitalWrite(YELLOW_LED, LOW);
    digitalWrite(GREEN_LED, LOW);
    sendSMS("Warning: Possible landslide detected!");
    delay(2000);
  } else if (moistureLevel > MOISTURE_THRESHOLD || abs(tilt) > (TILT_THRESHOLD / 2)) {
    // Moderate alert
    digitalWrite(BUZZER_PIN, LOW);
    digitalWrite(RED_LED, LOW);
    digitalWrite(YELLOW_LED, HIGH);
    digitalWrite(GREEN_LED, LOW);
  } else {
    // Normal status
    digitalWrite(BUZZER_PIN, LOW);
    digitalWrite(RED_LED, LOW);
    digitalWrite(YELLOW_LED, LOW);
    digitalWrite(GREEN_LED, HIGH);
  }

  delay(1000); // Delay to avoid rapid triggering
}

// Function to send SMS alerts
void sendSMS(String message) {
  gsm.println("AT+CMGF=1");  // Set SMS mode to text
  delay(1000);
  gsm.println("AT+CMGS=\"+91xxxxxxxxxx\"");  // Replace with the recipient's phone number
  delay(1000);
  gsm.println(message);
  delay(100);
  gsm.println((char)26);  // ASCII code of CTRL+Z to send the message
  delay(1000);
}

This code is responsible for reading sensor data, determining the risk of a landslide, and triggering alerts accordingly. It uses the Arduino Nano's analog and digital pins to interface with the sensors and the SoftwareSerial library to communicate with the GSM module. The accelerometer's tilt data is used alongside the soil moisture and vibration sensor readings to assess the landslide risk. Alerts are visually indicated by LEDs and audibly by the buzzer. SMS alerts are sent using the GSM module when a potential landslide is detected.