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

ESP32-Based Landslide Monitoring System with SMS Alerts

View and Edit Project In Cirkit DesignerImage of ESP32-Based Landslide Monitoring System with SMS Alerts

Circuit Documentation

Summary

The circuit in question appears to be designed for a landslide monitoring system that utilizes an ESP32 microcontroller to interface with various sensors and modules. The system is capable of measuring soil moisture, temperature, humidity, and pressure, and it can alert users to potential landslide conditions via SMS messages. The circuit includes power management components, sensors for environmental data collection, a GSM module for communication, and indicators for local alerts.

Component List

Power Sources

Microcontroller

Communication Module

Sensors

Indicators

Power Regulation

Switches

Connectors

Wiring Details

Power Management

Microcontroller (ESP32)

Communication Module

Sensors

Indicators

Switches

Connectors

Documented Code

The code provided is for the ESP32 microcontroller and is written in C++ for the Arduino platform. The code is responsible for initializing and reading from the various sensors, determining the alert level based on sensor readings, and sending SMS alerts when necessary.

#include <DHT.h>
#include <HX711.h>
#include <HardwareSerial.h>

// Define SIM800L pins
#define SIM800_TX 17  // ESP32 TX pin to SIM800L RX
#define SIM800_RX 16  // ESP32 RX pin to SIM800L TX

// Define LED and buzzer pins
#define greenLED 23
#define yellowLED 32
#define redLED 33
#define buzzer 25

// Define moisture sensor pins for ESP32
#define moistureSensor1 36
#define moistureSensor2 39
#define moistureSensor3 34

// Define DHT sensor pin and type
#define DHTPIN 35        // GPIO for DHT data pin
#define DHTTYPE DHT22   // DHT 22 (AM2302)

// Define HX711 pins for pressure sensor
#define LOADCELL_DOUT_PIN 21
#define LOADCELL_SCK_PIN 22

// Create instances for HX711, SIM800L, and DHT
HX711 scale;
HardwareSerial sim800(1);  // Use Serial1 on ESP32
DHT dht(DHTPIN, DHTTYPE);  // Initialize DHT sensor

// Define thresholds
int lowMoistureThreshold = 1600;  // Below this is wet (dangerous)
int highMoistureThreshold = 3000; // Above this is dry (safe)
float pressureThreshold = 3.0;   // Threshold in kg for red alert

// Phone number to send SMS
String phoneNumber = "+918075461115";  // Replace with your phone number

void setup() {
  Serial.begin(115200);
  sim800.begin(9600, SERIAL_8N1, SIM800_RX, SIM800_TX);

  // Initialize LED and buzzer pins
  pinMode(greenLED, OUTPUT);
  pinMode(yellowLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  pinMode(buzzer, OUTPUT);

  // Initialize DHT sensor
  dht.begin();

  // Initialize HX711 module
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  scale.set_scale();  // Calibrate scale to default
  scale.tare();       // Reset scale to zero

  Serial.println("Landslide Monitoring System Initialized with Temp, Humidity, and Pressure");
  delay(1000);
}

void loop() {
  // Read moisture sensor values
  int moistureValue1 = analogRead(moistureSensor1);
  int moistureValue2 = analogRead(moistureSensor2);
  int moistureValue3 = analogRead(moistureSensor3);
  int avgMoisture = (moistureValue1 + moistureValue2 + moistureValue3) / 3;

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

  // Read pressure from HX711
  float pressure = scale.get_units();  // Value in kg

  // Display sensor readings on Serial Monitor
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.print(" °C, Humidity: ");
  Serial.print(humidity);
  Serial.print(" %, Pressure: ");
  Serial.print(pressure);
  Serial.println(" kg");

  // Determine alert level
  if (avgMoisture < lowMoistureThreshold || pressure >= pressureThreshold) {
    // Red Alert for wet condition or high pressure
    digitalWrite(greenLED, LOW);
    digitalWrite(yellowLED, LOW);
    digitalWrite(redLED, HIGH);
    digitalWrite(buzzer, HIGH);
    Serial.println("Status: Red Alert (Dangerous - Wet or High Pressure)");

    // Send SMS for red alert
    sendSMS("Red Alert! High landslide risk detected.\nTemp: " + String(temperature) + " °C, Humidity: " + String(humidity) + " %