Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino-Based Accident Detection System with GPS and GSM

View and Edit Project In Cirkit DesignerImage of Arduino-Based Accident Detection System with GPS and GSM

Accident Detection System Documentation

Summary

This document provides a detailed overview of an Accident Detection System designed using an Arduino UNO microcontroller. The system detects changes in speed and collisions using an accelerometer. Upon detecting a collision, a buzzer sounds for 20 seconds, the GPS module senses the location and displays the coordinates on an LCD, and the GSM module calls and sends a message to an emergency number.

Component List

  1. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. ADXXL335

    • Description: 3-axis accelerometer.
    • Pins: VCC, X-OUT, Y-OUT, Z-OUT, GND
  3. GPS NEO 6M

    • Description: GPS module for location tracking.
    • Pins: VCC, RX, TX, GND
  4. LCD Display (16 pin)

    • Description: 16x2 character LCD display.
    • Pins: VSS, VDD, VO, RS, R_W, E, DB0, DB1, DB2, DB3, DB4, DB5, DB6, DB7, A, K
  5. Pushbutton

    • Description: Simple pushbutton switch.
    • Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)
  6. Piezo Speaker

    • Description: Small piezoelectric speaker.
    • Pins: pin1, pin2
  7. SIM 800L V2.0 GSM

    • Description: GSM module for communication.
    • Pins: SIM_TXD, VDD, SIM.RXD, 5V/4V, GND, RST
  8. Li-ion battery 18650-2000mAh 3.7V 7.4WH

    • Description: Rechargeable lithium-ion battery.
    • Pins: +, -

Wiring Details

Arduino UNO

ADXXL335

GPS NEO 6M

LCD Display (16 pin)

Pushbutton

Piezo Speaker

SIM 800L V2.0 GSM

Li-ion battery 18650-2000mAh 3.7V 7.4WH

Code Documentation

/*
 * Accident Detection System
 * This system detects changes in speed and collisions using an accelerometer.
 * If a collision is detected, a buzzer sounds for 20 seconds. The GPS module
 * senses the location and displays the coordinates on an LCD. The GSM module
 * calls and sends a message to an emergency number.
 */

#include <Wire.h>
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>

// Pin definitions
const int buzzerPin = 5;
const int buttonPin = 2;
const int gpsRxPin = 3;
const int gpsTxPin = 4;
const int gsmTxPin = 10;
const int gsmRxPin = 11;

// Accelerometer pins
const int xPin = A0;
const int yPin = A1;
const int zPin = A2;

// LCD pins
LiquidCrystal lcd(7, 8, 9, 12, 13, A3);

// Software serial for GPS and GSM
SoftwareSerial gpsSerial(gpsRxPin, gpsTxPin);
SoftwareSerial gsmSerial(gsmTxPin, gsmRxPin);

// Emergency number
const char emergencyNumber[] = "+1234567890";

void setup() {
  pinMode(buzzerPin, OUTPUT);
  pinMode(buttonPin, INPUT);
  lcd.begin(16, 2);
  gpsSerial.begin(9600);
  gsmSerial.begin(9600);
  Serial.begin(9600);
}

void loop() {
  int x = analogRead(xPin);
  int y = analogRead(yPin);
  int z = analogRead(zPin);

  if (detectCollision(x, y, z)) {
    soundBuzzer();
    String location = getGPSLocation();
    displayLocation(location);
    sendEmergencyAlert(location);
  }
}

bool detectCollision(int x, int y, int z) {
  // Simple collision detection logic
  return (x > 600 || y > 600 || z > 600);
}

void soundBuzzer() {
  digitalWrite(buzzerPin, HIGH);
  delay(20000); // 20 seconds delay
  digitalWrite(buzzerPin, LOW);
}

String getGPSLocation() {
  String location = "";
  while (gpsSerial.available()) {
    char c = gpsSerial.read();
    location += c;
  }
  return location;
}

void displayLocation(String location) {
  lcd.clear();
  lcd.print("Location:");
  lcd.setCursor(0, 1);
  lcd.print(location);
}

void sendEmergencyAlert(String location) {
  gsmSerial.print("ATD");
  gsmSerial.print(emergencyNumber);
  gsmSerial.println(";");
  delay(10000); // Wait for call to connect
  gsmSerial.println("ATH"); // Hang up
  gsmSerial.print("AT+CMGF=1\r");
  delay(100);
  gsmSerial.print("AT+CMGS=\"");
  gsmSerial.print(emergencyNumber);
  gsmSerial.println("\"");
  delay(100);
  gsmSerial.print("Accident detected at: ");
  gsmSerial.print(location);
  gsmSerial.write(26); // Ctrl+Z to send SMS
}

This code initializes the necessary components and continuously monitors the accelerometer readings. If a collision is detected, it triggers the buzzer, retrieves the GPS location, displays it on the LCD, and sends an emergency alert via the GSM module.