IoT-Based Accident Detection and Health Monitoring System Using Raspberry Pi with GSM, GPS and Camera Integration

 

Accident Detection & Health Monitoring System using Raspberry Pi

Your project is a complete IoT-based smart vehicle safety system that integrates motion sensing, biometric monitoring, GPS tracking, GSM communication, camera surveillance, and embedded display into one life-saving platform.

Below is a refined technical explanation + improvement suggestions + cloud logging architecture to elevate your project to a professional, publishable level.


 System Architecture Overview

 Core Controller

  • Raspberry Pi (Central Processing Unit)

 Location Tracking

  • GPS Module (UART-based real-time coordinates)

 Emergency Communication

  • GSM Module (AT command-based SMS alerts)

 Incident Capture

  • Raspberry Pi Camera Module (Image Evidence)

Health Monitoring Sensors

  • Heart Pulse Sensor

  • MPU6050 (Acceleration + Tilt Detection)

  • BMP388 (Temperature + Pressure)

 Display Interface

  • OLED SSD1306 via I2C

 Power System

  • 3S LiPo Battery

  • Solar Panel Charging

  • DC-DC Buck Converter

  • Power Stabilization Capacitors


 Working Logic (Improved Professional Flow)

1️⃣ Continuous Monitoring Loop

  • MPU6050 monitors:

    • Sudden acceleration

    • Tilt angle

    • Rapid deceleration

  • Heart sensor monitors pulse rhythm

  • BMP388 reads environmental data

2️⃣ Accident Detection Algorithm (Recommended Upgrade)

Instead of checking only a pulse trigger, add an acceleration threshold:

accel_magnitude = (accel_data['x']**2 + accel_data['y']**2 + accel_data['z']**2)**0.5

if accel_magnitude > 20: # Adjust threshold experimentally
accident_detected = True

You can also detect:

  • Roll angle > 60°

  • Sudden negative acceleration spike

This improves accuracy and reduces false alarms.


🔷 Emergency Event Execution

When accident_detected = True:

  1.  Capture Image

  2.  Fetch GPS Coordinates

  3.  Send SMS Alert

  4.  Display Emergency Message

  5.  Log Data to File or Cloud


🔷 Suggested Professional SMS Format

🚨 ACCIDENT ALERT 🚨
Vehicle ID: V102
Time: 14:32:10
Location: https://maps.google.com/?q=12.9716,77.5946
Heart Status: Abnormal
Immediate assistance required.

Including a Google Maps clickable link improves usability.


 Code Improvement Suggestions

✅ 1. Prevent GPS Blocking

Your current get_gps_data() may block. Add timeout handling.

✅ 2. Avoid Re-initializing GPIO Every Loop

Move:

GPIO.setup(HEART_PULSE_PIN, GPIO.IN)

outside the main loop.

✅ 3. Add Debounce & Confirmation Logic

Before sending SMS, confirm accident for 3 consecutive readings to avoid false alarms.

✅ 4. Store Incident Log Locally

with open("incident_log.txt", "a") as f:
f.write(f"{time.ctime()} | {lat}, {lon} | {accel_magnitude}\n")

 Cloud-Based Data Logging (Future Enhancement)

To implement cloud database storage:

Option 1: Firebase

  • Install firebase-admin SDK

  • Push JSON data

  • Create real-time dashboard

Option 2: ThingsBoard

  • MQTT protocol integration

  • Real-time vehicle dashboard

Option 3: AWS IoT Core

  • MQTT publishing

  • Lambda alert triggers

Example MQTT Publishing:

import paho.mqtt.publish as publish

publish.single(
"vehicle/emergency",
payload=json_data,
hostname="broker.hivemq.com"
)

 Advanced Feature Upgrades

 AI-Based Accident Prediction

  • Train ML model using acceleration patterns

  • Use TensorFlow Lite on Raspberry Pi

 Mobile App Integration

  • Flutter app

  • Real-time GPS tracking

  • Push notifications

 Automatic Ambulance Dispatch

  • Integrate API with emergency services

  • Auto-send data packet

 Voice Alert System

Add speaker + pre-recorded alert:

"Accident detected. Emergency message sent."


 Power Management Optimization

For real deployment:

  • Use BMS for LiPo safety

  • Add over-voltage and short-circuit protection

  • Use 5V 10A buck converter minimum

  • Add heat dissipation for GSM module


 Real-World Applications

✔ Smart car accident detection
✔ Two-wheeler safety monitoring
✔ Fleet vehicle tracking
✔ Ambulance smart automation
✔ Elderly travel health monitoring
✔ Industrial vehicle safety


 Why This Is a Strong Final-Year / Research-Level Project

  • Multi-sensor data fusion

  • Real-time embedded processing

  • GSM + GPS integration

  • IoT-ready architecture

  • Expandable to AI & cloud

  • Energy-independent design

Code:

import time
import RPi.GPIO as GPIO
import serial
import picamera2
from gps3 import gps3
from smbus2 import SMBus
from bmp388 import BMP388
from mpu6050 import mpu6050
from luma.core.interface.serial import i2c
from luma.oled.device import ssd1306
from luma.core.render import canvas
from PIL import ImageFont

# GPIO Setup
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

# Initialize GPS
gps_socket = gps3.GPSDSocket()
data_stream = gps3.DataStream()
gps_socket.connect()
gps_socket.watch()

# Initialize GSM (Serial communication)
gsm_serial = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=1)

# Initialize Camera
camera = picamera2.Picamera2()
camera.configure(camera.create_still_configuration())

# Initialize I2C Bus
i2c_bus = SMBus(1)

# Initialize BMP388 Sensor
bmp388 = BMP388(i2c_bus)

# Initialize MPU-6050 Sensor
mpu = mpu6050(0x68)

# Initialize OLED Display
serial_interface = i2c(port=1, address=0x3C)
oled = ssd1306(serial_interface)
font = ImageFont.load_default()

# Heart Pulse Sensor Pin
HEART_PULSE_PIN = 4

# Example Function to Read GPS Data
def get_gps_data():
    try:
        for new_data in gps_socket:
            if new_data:
                data_stream.unpack(new_data)
                latitude = data_stream.TPV['lat']
                longitude = data_stream.TPV['lon']
                return latitude, longitude
    except Exception as e:
        print(f"GPS error: {e}")
        return None, None

# Example Function for GSM Communication
def send_sms(message, phone_number):
    try:
        gsm_serial.write(b'AT+CMGF=1\r')  # Set SMS mode
        time.sleep(1)
        gsm_serial.write(f'AT+CMGS="{phone_number}"\r'.encode())
        time.sleep(1)
        gsm_serial.write(f"{message}\x1A".encode())  # Send message
        time.sleep(3)
    except Exception as e:
        print(f"GSM error: {e}")

# Example Function to Read Heart Pulse Sensor
def read_heart_pulse():
    GPIO.setup(HEART_PULSE_PIN, GPIO.IN)
    return GPIO.input(HEART_PULSE_PIN)

# Main Execution
if __name__ == "__main__":
    try:
        while True:
            # Capture Image
            camera.start_and_capture_file("image.jpg")
            print("Image captured.")

            # Read GPS Data
            lat, lon = get_gps_data()
            if lat and lon:
                print(f"Location: Latitude {lat}, Longitude {lon}")

            # Read BMP388 Sensor Data
            temperature, pressure = bmp388.read_temperature_and_pressure()
            print(f"Temperature: {temperature} C, Pressure: {pressure} Pa")

            # Read MPU-6050 Sensor Data
            accel_data = mpu.get_accel_data()
            gyro_data = mpu.get_gyro_data()
            print(f"Accelerometer: {accel_data}, Gyroscope: {gyro_data}")

            # Display Data on OLED
            with canvas(oled) as draw:
                draw.text((0, 0), f"Temp: {temperature} C", font=font, fill=255)
                draw.text((0, 10), f"Pressure: {pressure} Pa", font=font, fill=255)
                draw.text((0, 20), f"Lat: {lat}", font=font, fill=255)
                draw.text((0, 30), f"Lon: {lon}", font=font, fill=255)

            # Check Heart Pulse Sensor
            heart_pulse = read_heart_pulse()
            print(f"Heart Pulse Sensor: {heart_pulse}")

            # Send Emergency SMS if Heart Pulse Sensor is Triggered
            if heart_pulse == 1:  # Example condition
                message = f"Emergency detected at location: {lat}, {lon}"
                send_sms(message, "+1234567890")  # Replace with recipient's number

            time.sleep(5)  # Adjust the loop delay
    except KeyboardInterrupt:
        print("Exiting program.")
    finally:
        GPIO.cleanup()

 Health Monitoring Integration

The system monitors critical health parameters such as:

  • Heart rate

  • Body temperature

  • Oxygen level (SpO2, if sensor included)

If abnormal readings are detected (for example, irregular heart rate), the system can trigger medical alerts even without an accident.

 Camera Module for Evidence Capture

The integrated camera captures real-time images or short video clips during an accident. This helps in:

  • Insurance verification

  • Emergency assessment

  • Incident documentation

OLED / Digital Display Interface

The display provides:

  • Health status readings

  • GPS signal confirmation

  • Network status

  • Emergency alert confirmation

Solar & LiPo Power Management

The system includes:

  • Solar panel charging

  • DC-DC buck converter for voltage regulation

  • 3S LiPo battery backup

  • Capacitor-based power stabilization

This ensures continuous operation even during power interruptions.


Key Technical Features

  • Raspberry Pi GPIO interfacing

  • GSM communication via UART

  • GPS module integration

  • Real-time accident detection algorithm

  • Health sensor data acquisition

  • Image capture using camera module

  • OLED I2C communication

  • Solar charging and battery management

  • Emergency automation system


 Working Flow

  1. System initializes sensors and communication modules.

  2. Continuously monitors acceleration and health parameters.

  3. If sudden impact or abnormal health condition is detected:

    • Captures image

    • Fetches GPS coordinates

    • Sends SMS alert via GSM

    • Displays emergency message

  4. Logs data for future analysis.


 Applications

  • Smart vehicle safety system

  • Two-wheeler and car accident alert system

  • Fleet management safety monitoring

  • Ambulance automation support system

  • Elderly health and travel monitoring

  • IoT-based medical emergency system

  • Smart transportation security


 Future Enhancements

  • Cloud-based real-time dashboard

  • Mobile app integration

  • AI-based accident prediction

  • Automatic ambulance dispatch integration

  • Voice alert system

  • Data logging to cloud database

 

IOT & SMART SYSTEM PROJECTS

  1. IoT Weather Monitoring System (NodeMCU ESP8266 + DHT11 + Rain Sensor)
  2. ESP8266 NodeMCU Smart Health & Environment Monitoring System with Pulse, Temperature and Motion Sensors
  3. ESP32 Wi-Fi Weight Sensor with HX711
  4. Smart RFID Access Control System Using ESP32 Dev Board and UHF RFID Reader Module
  5. Smart IoT Motor Control System Using ESP32 Dev Board and L298N Motor Driver Module
  6. Smart Waste Management System Using Arduino Nano, Ultrasonic Sensor & GSM Module – Solar Powered IoT Solution
  7. Raspberry Pi Zero W and GSM SIM900 Based Ultrasonic Distance Measurement System
  8. Arduino UNO Smart Surveillance System with ESP8266 WiFi, PIR Motion Sensor & Camera Module
  9. Arduino UNO Environmental Monitoring System with OLED & 16x2 I2C LCD Display
  10. Arduino UNO-Based Smart Home Automation System with Flame and IR Sensors 
  11. Arduino Nano-Based Landslide Detection System with GSM Alerts – Smart Disaster Monitoring Project
  12. Arduino Nano Rain-Sensing Stepper Motor System
  13. Arduino Based Automatic Tire Inflator Using Pressure Sensor, Relay Module and LCD Display
  14. Arduino-Based Automatic Cooker Using Servo Motors, DC Stirrer Motor, Temperature Sensor and Relay-Controlled Heater
  15. Arduino Sketch for Plastic Bottle and Can Reverse Vending Machine

 TRAFFIC & SMART CITY PROJECTS
  1. RFID-Based Smart Traffic Control System (Arduino Mega)
  2. Arduino UNO Traffic Light Control System – Smart LED Signal Project
  3.  Arduino UNO Controlled Traffic Light System with Joystick Interface

ROBOTICS PROJECTS
  1. Arduino UNO Smart Obstacle Avoiding Robot (Ultrasonic + IR + GSM)
  2. Arduino-Powered Autonomous Obstacle Avoidance Robot with Servo Control
  3. Arduino Nano Bluetooth Controlled Line Follower Robot Using L298N Motor Driver
  4. Arduino UNO Bluetooth Controlled 4WD Robot Car Using L298N Motor Driver
  5. Arduino UNO Multi-Sensor Obstacle Avoidance & Bluetooth Controlled Robot Car Using L298N
  6. Raspberry Pi Motor Control Robot (L298N + Li-ion)
  7. RC Car Simulation with L298N Motor Driver and Joystick Control using Arduino (CirkitDesign Simulation)
  8. Raspberry Pi Robotic Arm Control System with Camera Module and Motor Driver – Smart Automation & Vision-Based Robotics Project
  9. ESP32-Based 4WD Robot Car Using Dual L298N Motor Drivers – Circuit Diagram and IoT Control Project

LORA & WIRELESS COMMUNICATION PROJECTS
  1. Arduino LoRa Communication Project Using Adafruit RFM95W LoRa RadioArduino Nano with RFM95 SX1276 LoRa
  2. Arduino Nano with RFM95 LoRa SX1276 Module – Long Range Wireless Communication Project
  3. Arduino Nano Digital Clock Using DS3231 RTC and TM1637 4-Digit Display – Circuit Diagram and Project Guide

 LED, LIGHTING & DISPLAY PROJECTS
  1. Arduino UNO Controlled NeoPixel Ring Light Show
  2. Wi-Fi Controlled NeoPixel Ring (ESP8266)
  3. Chained NeoPixel Rings with Arduino – Addressable RGB LED Control Project
  4. Arduino Nano-Controlled Lighting System with Gesture and Sound Interaction
  5. Raspberry Pi GPIO Multi-LED Control System – Beginner-Friendly Embedded Electronics Project
  6. 4 Channel Relay Module with Arduino UNO

 SENSOR & DETECTION PROJECTS
  1. Arduino UNO Color Sensor + Proximity System (TCS3200 + Inductive)
  2. Arduino Color Detection Project Using Adafruit TCS34725 RGB Color Sensor
  3. Arduino Gas Leakage Detection and Safety Alert System Using MQ-2 Gas Sensor
  4. MQ-135 Air Quality Detector Using Arduino | Cirkit Designer Simulation Project
  5. Pulse Sensor Using Arduino – Complete Guide with Simulation 
  6. HX711 Load Sensor Demo Using Arduino | Digital Weight Measurement Project
  7. Track Time with DS1307 RTC and Display on Arduino Uno with 16x2 LCD | Cirkit Designer Project
  8. Parking Sensor Simulator using Arduino Uno and HC-SR04 Ultrasonic Sensor

 FUN & INTERACTIVE PROJECTS
  1. Pong Game with Arduino UNO and OLED Display – Project Explanation
  2.   Arduino UNO Bluetooth-Controlled Servo Motor System
  3. Arduino UNO-Based Interactive Touch and Distance Sensing System with LED Indicators and Servo Control

 INDUSTRIAL / AUTOMATION PROJECTS
  1. Arduino UNO Smart Waste Sorting System Using Ultrasonic Sensor, Moisture Sensor, Servo, Stepper Motor and LCD
  2. Arduino-Based Smart Waste Segregation System Using Metal, Plastic and Moisture Sensors with Stepper and Servo Control
  3. ESP32-Based Digital Weighing Scale Using 50kg Load Cell, HX711 Module and 16x2 LCD Display
  4. Arduino-Based Smart Toll Gate Automation System with RFID, GSM, Ultrasonic Sensor and LCD Display

  5. Arduino-Based Automatic Pill Dispenser Machine with LCD Display, Servo Motor and Buzzer Reminder

  6. Arduino UNO Smart Water Quality Monitoring System with pH Sensor, Turbidity Sensor and LCD Display

  7. Arduino-Based Ocean Cleaning Boat Robot with Dual IBT-2 Motor Drivers and Conveyor Belt System

  8. IoT-Based Accident Detection and Health Monitoring System Using Raspberry Pi with GSM, GPS and Camera Integration

  9. Raspberry Pi RFID and Keypad Based Smart Door Lock System with LCD Display and L298N Motor Driver

  10. Smart Shopping Trolley Using Arduino UNO & RFID | Automatic Billing System

  11. Arduino UNO Based Automatic Liquid Hand Sanitizer & Soap Dispenser System

  12. Arduino Based Robotic Weeding Machine with Ultrasonic Obstacle Detection and L298N Motor Driver

  13. Arduino UNO Based Biometric Electronic Voting System with LCD Display and Fingerprint Authentication

  14. Arduino UNO Based Electronic Voting System with ILI9341 TFT Display

Comments