Arduino UNO Based Soil Moisture Monitoring with GSM Alert System
View and Edit Project In Cirkit Designer
Landslide Early Detection Device Documentation
Summary
The Landslide Early Detection Device is designed to monitor soil moisture levels and send an SMS alert if the moisture level falls below a predefined threshold, indicating potential landslide conditions. The circuit utilizes an Arduino UNO as the main controller, interfaced with a Soil Moisture Sensor for detecting moisture levels and a SIM 800L V2.0 GSM module for sending SMS alerts. The Soil Moisture Module provides an interface between the sensor and the Arduino.
Component List
Arduino UNO
- Microcontroller board based on the ATmega328P
- It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.
Soil Moisture Sensor
- A simple breakout for measuring the moisture in soil and similar materials.
- It has three pins: VCC, GND, and SIG (Signal).
Soil Moisture Module
- An interface module for the Soil Moisture Sensor.
- It has six pins: positive, negative, Analog, Digital, Ground, and VCC.
SIM 800L V2.0 GSM
- A GSM/GPRS module that can provide internet access via cellular networks.
- It has six pins: SIM_TXD, VDD, SIM.RXD, 5V/4V, GND, and RST.
Wiring Details
Arduino UNO
- 3.3V connected to Soil Moisture Module VCC
- 5V connected to SIM 800L V2.0 GSM 5V/4V
- GND connected to SIM 800L V2.0 GSM GND, Soil Moisture Module Ground, and Soil Moisture Sensor GND
- A0 connected to Soil Moisture Sensor SIG through Soil Moisture Module Analog
- D10 connected to SIM 800L V2.0 GSM SIM_TXD
- D11 connected to SIM 800L V2.0 GSM SIM.RXD
Soil Moisture Sensor
- VCC connected to Soil Moisture Module positive
- GND connected to Soil Moisture Module negative
- SIG connected to Arduino UNO A0 through Soil Moisture Module Analog
Soil Moisture Module
- VCC connected to Arduino UNO 3.3V
- Ground connected to Arduino UNO GND
- Analog connected to Soil Moisture Sensor SIG and Arduino UNO A0
- positive connected to Soil Moisture Sensor VCC
- negative connected to Soil Moisture Sensor GND
SIM 800L V2.0 GSM
- 5V/4V connected to Arduino UNO 5V
- GND connected to Arduino UNO GND
- SIM_TXD connected to Arduino UNO D10
- SIM.RXD connected to Arduino UNO D11
Documented Code
/*
* Landslide Early Detection Device
* This code reads the soil moisture sensor value and sends an SMS alert
* using the SIM800L module if the moisture level falls below a threshold.
*/
#include <SoftwareSerial.h>
// Pin definitions
const int soilMoisturePin = A0;
const int simTxPin = 10;
const int simRxPin = 11;
// Threshold for soil moisture
const int moistureThreshold = 200;
// Create a software serial port for SIM800L
SoftwareSerial sim800l(simTxPin, simRxPin);
void setup() {
// Initialize serial communication
Serial.begin(9600);
sim800l.begin(9600);
// Initialize soil moisture sensor pin
pinMode(soilMoisturePin, INPUT);
// Wait for SIM800L to initialize
delay(1000);
// Send initial AT command to check communication
sim800l.println("AT");
delay(1000);
if (sim800l.available()) {
Serial.println(sim800l.readString());
}
}
void loop() {
// Read soil moisture value
int soilMoistureValue = analogRead(soilMoisturePin);
Serial.print("Soil Moisture Value: ");
Serial.println(soilMoistureValue);
// Check if soil moisture is below threshold
if (soilMoistureValue <= moistureThreshold) {
sendSMS("Landslide detected!");
}
// Wait for a while before next reading
delay(10000);
}
void sendSMS(String message) {
// Set SMS mode to text
sim800l.println("AT+CMGF=1");
delay(1000);
// Send SMS to the number saved on the SIM card
sim800l.println("AT+CMGS=\"+1234567890\""); // Replace with actual number
delay(1000);
sim800l.print(message);
delay(1000);
sim800l.write(26); // ASCII code for CTRL+Z to send the message
delay(1000);
// Print response from SIM800L
if (sim800l.available()) {
Serial.println(sim800l.readString());
}
}
This code is responsible for initializing the Arduino UNO and its peripherals, reading the soil moisture level, and using the SIM800L module to send an SMS alert if the moisture level is below the set threshold. The sendSMS function is used to send the actual message. The code is written in Arduino's C++-like language and should be uploaded to the Arduino UNO using the Arduino IDE.