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

ESP32-Based Landslide Monitoring System with SMS Alerts

Image 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

  • 3.7v Battery: Provides the primary power source for the circuit.
  • Step Up Boost Power Converter, Adjustable Voltage Regulator: Steps up the voltage from the battery to a higher, regulated voltage for other components.

Microcontroller

  • ESP32: The main microcontroller unit that controls the sensors, processes the data, and communicates with the GSM module.

Communication Module

  • SIM800L GSM Module: Allows the system to send SMS messages for alerts.

Sensors

  • Water Sensors: Detect the presence of water.
  • Soil Moisture Modules: Measure the moisture level in the soil.
  • DHT11: Measures temperature and humidity.
  • HX711 Weighing Sensor Module: Interfaces with a load cell to measure pressure.
  • Load Cell: Measures the pressure or weight on it.

Indicators

  • LEDs (Red, Green, Yellow): Indicate the status of the system.
  • Buzzer: Provides an audible alert.

Power Regulation

  • 7805 Voltage Regulator: Regulates the voltage to a steady 5V output.

Switches

  • Rocker Switch: Allows manual power control to the circuit.

Connectors

  • Terminal PCB 2 Pin: Used for making easy and secure connections to the board.

Wiring Details

Power Management

  • 3.7v Battery:

    • + to Step Up Boost Power Converter VIN+
    • - to Rocker Switch input and other - terminals as needed.
  • Step Up Boost Power Converter, Adjustable Voltage Regulator:

    • VOUT+ to 7805 Vin and other + terminals as needed.
    • VOUT- to GND terminals.
  • 7805 Voltage Regulator:

    • Vin from Step Up Boost Power Converter VOUT+
    • Gnd to GND terminals.
    • Vout to VCC terminals of sensors and ESP32 VIN.

Microcontroller (ESP32)

  • ESP32:
    • EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, VIN, 3V3, D15, D2, D4, RX2, TX2, D5, D18, D19, D21, RX0, TX0, D22, D23, BOOT connected as per the net list and code requirements.

Communication Module

  • SIM800L GSM Module:
    • TXD to ESP32 RX2
    • RXD to ESP32 TX2
    • GND to GND terminals.
    • VCC to 3.7v Battery +.

Sensors

  • Water Sensors:

    • - to GND terminals.
    • + to positive terminals of Soil Moisture Modules.
  • Soil Moisture Modules:

    • Analog to ESP32 VP, VN, D34 respectively.
    • Ground to GND terminals.
    • VCC to 7805 Vout.
  • DHT11:

    • DATA to ESP32 D35
    • GND to GND terminals.
    • VCC to 7805 Vout.
  • HX711 Weighing Sensor Module:

    • A-, A+, E-, E+ to corresponding Load Cell pins.
    • GND to GND terminals.
    • VCC to 7805 Vout.
    • DO/RX to ESP32 D21
    • CK/TX to ESP32 D22.
  • Load Cell:

    • E+, A-, E-, A+ to corresponding HX711 pins.

Indicators

  • LEDs (Red, Green, Yellow):

    • anode to ESP32 D32, D33, D23 respectively.
    • cathode to GND terminals.
  • Buzzer:

    • PIN to ESP32 D25
    • GND to GND terminals.

Switches

  • Rocker Switch:
    • output to SIM800L GND and Step Up Boost Power Converter VIN-.

Connectors

  • Terminal PCB 2 Pin: Used to connect various + and - terminals to corresponding power lines and GND.

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) + " %