Arduino UNO Based Accident Detection and SOS Alert System with GPS and GSM
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
The circuit in question is designed to monitor for accidents using an accelerometer and a piezo sensor. Upon detecting an accident, it activates an SOS signal and sends an SMS with the location coordinates obtained from a GPS module. The system is built around an Arduino UNO microcontroller, which interfaces with an MPU-6050 accelerometer, a Neo 6M GPS module, a Sim800l GSM module for communication, and a piezo sensor for impact detection. A resistor and a diode are also included for circuit protection and signal conditioning.
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.
MPU-6050
- A 6-axis motion tracking device that combines a 3-axis gyroscope and a 3-axis accelerometer on the same silicon die.
- It has an I2C interface for communication.
Neo 6M GPS Module
- A standalone GPS receiver module that provides a solution for positioning and navigation.
- It communicates with the microcontroller via serial communication.
Sim800l
- A GSM/GPRS module that can provide SMS and voice communication capabilities to embedded systems.
- It communicates with the microcontroller via serial communication.
Piezo Sensor
- A device that can measure changes in pressure, acceleration, temperature, strain, or force by converting them to an electrical charge.
Resistor (1 MΩ)
- A passive two-terminal electrical component that implements electrical resistance as a circuit element.
1N4007 Rectifier Diode
- A standard silicon diode used to protect sensitive electronics against voltage spikes and to rectify AC into DC.
Wiring Details
Arduino UNO
3.3Vconnected to Sim800l VCC5Vconnected to MPU-6050 VCC and Neo 6M GPS Module VCCGNDconnected to MPU-6050 GND, Neo 6M GPS Module GND, Sim800l GND, and Piezo Sensor (-)A1connected to one end of the Resistor (other end connected to Piezo Sensor (+))A4(SDA) connected to MPU-6050 SDAA5(SCL) connected to MPU-6050 SCLD2connected to Sim800l TXDD3connected to Sim800l RXD and Neo 6M GPS Module TXD4connected to Neo 6M GPS Module RX
MPU-6050
VCCconnected to Arduino UNO 5VGNDconnected to Arduino UNO GNDSDAconnected to Arduino UNO A4SCLconnected to Arduino UNO A5
Neo 6M GPS Module
VCCconnected to Arduino UNO 5VGNDconnected to Arduino UNO GNDRXconnected to Arduino UNO D4TXconnected to Arduino UNO D3 (also connected to Sim800l RXD)
Sim800l
VCCconnected to Arduino UNO 3.3VGNDconnected to Arduino UNO GND (also connected to the Anode of the 1N4007 Diode)RXDconnected to Arduino UNO D3 (also connected to Neo 6M GPS Module TX)TXDconnected to Arduino UNO D2
Piezo Sensor
+connected to one end of the Resistor (other end connected to Arduino UNO A1)-connected to Arduino UNO GND (also connected to the Cathode of the 1N4007 Diode)
Resistor (1 MΩ)
- One end connected to Arduino UNO A1
- Other end connected to Piezo Sensor (+)
1N4007 Rectifier Diode
Anodeconnected to Sim800l GNDCathodeconnected to Piezo Sensor (+)
Documented Code
#include <Wire.h>
#include <MPU6050.h>
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
MPU6050 accelgyro;
TinyGPSPlus gps;
SoftwareSerial gpsSerial(3, 4); // RX, TX for GPS
SoftwareSerial gsmSerial(2, 3); // RX, TX for GSM
const int piezoPin = A1; // Piezo sensor connected to A1
const int piezoThreshold = 500; // Threshold for piezo force detection
const int accelThreshold = 16000; // Threshold for accelerometer
void setup() {
Serial.begin(9600);
gpsSerial.begin(9600);
gsmSerial.begin(9600);
// Initialize accelerometer
Wire.begin();
accelgyro.initialize();
if (!accelgyro.testConnection()) {
Serial.println("Accelerometer not connected!");
}
}
void loop() {
// Check for accident via accelerometer or piezo sensor
if (detectAccident() || analogRead(piezoPin) > piezoThreshold) {
activateSOS();
}
}
bool detectAccident() {
int16_t ax, ay, az;
accelgyro.getAcceleration(&ax, &ay, &az);
return (abs(ax) > accelThreshold || abs(ay) > accelThreshold || abs(az) > accelThreshold);
}
void activateSOS() {
Serial.println("SOS Activated! Accident detected.");
sendSMS();
}
void sendSMS() {
if (gps.location.isValid()) {
String message = "Accident detected! Location: ";
message += "Lat: " + String(gps.location.lat(), 6) + ", ";
message += "Lng: " + String(gps.location.lng(), 6);
gsmSerial.println("AT+CMGF=1"); // Set SMS to text mode
delay(100);
gsmSerial.println("AT+CMGS=\"+1234567890\""); // Replace with emergency contact number
delay(100);
gsmSerial.print(message);
gsmSerial.write(26); // End message with Ctrl+Z
} else {
Serial.println("GPS location not valid.");
}
}
This code is designed to run on the Arduino UNO and utilizes the MPU-6050 accelerometer to detect sudden changes in acceleration, indicative of an accident. When an accident is detected, it sends an SMS with the current GPS coordinates using the Sim800l GSM module. The piezo sensor is used as an additional means of detecting an impact. The code includes initialization and continuous monitoring in the setup and loop functions, respectively. The detectAccident function checks for high acceleration events, and the activateSOS function handles the SOS activation and SMS sending logic.