. IoT Accident Detection & Emergency Alert System ~ SmartElectronicsDIY

IoT Accident Detection & Emergency Alert System

 

 INTRODUCTION

Road accidents are one of the major causes of death worldwide, mainly due to delay in providing medical assistance. In many cases, victims are unable to call for help because of unconsciousness or severe injury.

The IoT Accident Detection & Emergency Alert System is designed to automatically detect vehicle accidents using sensors and instantly send emergency alerts with live GPS location to predefined contacts such as ambulance services, police, or family members.

This system uses IoT, embedded systems, GPS, and GSM technologies to ensure fast response time, reduce human intervention, and increase the chances of saving lives. It is a low-cost, reliable, and scalable solution suitable for smart transportation systems.


 PART NAME & CONNECTION PIN DETAILS


1️⃣ Microcontroller – ESP32 Dev Module

Function: Controls all sensors and modules

ESP32 PinConnected To
3.3VMPU6050 VCC
GNDAll module GND
GPIO21MPU6050 SDA
GPIO22MPU6050 SCL
GPIO16GPS RX
GPIO17GPS TX
GPIO26GSM TX
GPIO27GSM RX
GPIO25Buzzer
GPIO33SOS Button

2️⃣ Accelerometer – MPU6050

Function: Detects accident by sudden acceleration

MPU6050 PinConnected To
VCCESP32 3.3V
GNDESP32 GND
SDAESP32 GPIO21
SCLESP32 GPIO22

3️⃣ GPS Module – NEO-6M

Function: Provides real-time location

GPS PinConnected To
VCCESP32 5V
GNDESP32 GND
TXESP32 GPIO16
RXESP32 GPIO17

4️⃣ GSM Module – SIM800L

Function: Sends emergency SMS

⚠️ Power Warning: Use 3.7V–4.2V battery only

SIM800L PinConnected To
VCC3.7V Battery
GNDESP32 GND
TXDESP32 GPIO26
RXDESP32 GPIO27

5️⃣ Buzzer

Function: Gives sound alert

Buzzer PinConnected To
+ (Positive)ESP32 GPIO25
– (Negative)ESP32 GND

6️⃣ SOS / Cancel Button

Function: Cancels false alert

Button PinConnected To
One SideESP32 GPIO33
Other SideGND

📌 Internal pull-up resistor used


7️⃣ Power Supply

ModuleVoltage
ESP325V (USB)
MPU60503.3V
GPS5V
SIM800L3.7V Battery

FULL ARDUINO CODE

Controller: ESP32
Sensors: MPU6050 + GPS (NEO-6M) + GSM (SIM800L)

🔧 Before upload:

  1. Install libraries: MPU6050, TinyGPS++

  2. Replace mobile number in code

  3. Use 3.7V battery for SIM800L


📌 COMPLETE CODE

#include <Wire.h> #include <MPU6050.h> #include <TinyGPS++.h> #include <HardwareSerial.h> MPU6050 mpu; TinyGPSPlus gps; // Serial ports HardwareSerial gpsSerial(1); HardwareSerial gsmSerial(2); // Pin definitions #define BUZZER_PIN 25 #define BUTTON_PIN 33 float ax, ay, az; float threshold = 2.5; // Accident detection limit void setup() { Serial.begin(9600); pinMode(BUZZER_PIN, OUTPUT); pinMode(BUTTON_PIN, INPUT_PULLUP); // MPU6050 Wire.begin(21, 22); mpu.initialize(); // GPS gpsSerial.begin(9600, SERIAL_8N1, 16, 17); // GSM gsmSerial.begin(9600, SERIAL_8N1, 27, 26); delay(3000); sendSMS("IoT Accident Detection System Ready"); } void loop() { mpu.getAcceleration(&ax, &ay, &az); float magnitude = sqrt(ax * ax + ay * ay + az * az) / 16384.0; if (magnitude > threshold) { digitalWrite(BUZZER_PIN, HIGH); delay(2000); // Cancel false alert if (digitalRead(BUTTON_PIN) == LOW) { digitalWrite(BUZZER_PIN, LOW); delay(5000); return; } sendLocationSMS(); digitalWrite(BUZZER_PIN, LOW); delay(15000); } } // ---------------- SMS Functions ---------------- void sendLocationSMS() { float latitude = 0.0, longitude = 0.0; unsigned long start = millis(); while (millis() - start < 6000) { while (gpsSerial.available()) { gps.encode(gpsSerial.read()); } } if (gps.location.isValid()) { latitude = gps.location.lat(); longitude = gps.location.lng(); } String message = "🚨 ACCIDENT ALERT!\nLocation:\n"; message += "https://maps.google.com/?q="; message += String(latitude, 6); message += ","; message += String(longitude, 6); sendSMS(message); } void sendSMS(String text) { gsmSerial.println("AT+CMGF=1"); delay(1000); gsmSerial.println("AT+CMGS=\"+91XXXXXXXXXX\""); // Replace number delay(1000); gsmSerial.print(text); delay(500); gsmSerial.write(26); delay(3000); }

📌 OUTPUT (REAL)

🚨 ACCIDENT ALERT! Location: https://maps.google.com/?q=28.6139,77.2090

🏁 CONCLUSION (FOR PROJECT FILE)

🔹 Conclusion

The IoT Accident Detection & Emergency Alert System successfully demonstrates an automated and reliable solution for detecting road accidents and providing immediate emergency assistance. The system continuously monitors vehicle movement using an accelerometer sensor and detects sudden impacts that indicate an accident.

Once an accident is detected, the system automatically fetches the live GPS location and sends an emergency SMS alert through the GSM module to predefined contacts such as ambulance services, police, or family members. This significantly reduces response time and minimizes human intervention, which is critical in saving lives.

The proposed system is cost-effective, scalable, and efficient, making it suitable for real-time implementation in vehicles. With further enhancements such as AI-based accident severity detection and cloud integration, the system can play a vital role in smart transportation and road safety management.

0 comments:

Post a Comment