Project tutorial
Live Tracking and Accident Detection System

Live Tracking and Accident Detection System

If an accident or any gas or smoke leakage is detected, it notifies through call and through Blynk app.

  • 2,989 views
  • 1 comment
  • 16 respects

Components and supplies

Apps and online services

About this project

Every day around the world, a large percentage of people die from traffic accident injuries. An influential indicator of survival rates after detecting the accident is the time between the occurrence of the accident and the arrival of emergency responders to the scene. Reductions in this time, in turn, may affect the numbers of fatalities, and this is achieved through using automatic traffic accident detection and notification systems which are either built-in the modern vehicles or available in the roads. In this system, it detects whether accident occurs or not using accelerometer and it notifies to some numbers through call and then they check using blynk app where location will be traced. In addition to that whether any smoke or gas leakage also it detects and notifies through Blynk app.

Code

Accident_detectionArduino
using accelerometer readings x,y,z range we detect accident.
#include "TinyGPS++.h"
#include "SoftwareSerial.h"
SoftwareSerial GPRS(2,3);
SoftwareSerial serial_connection(10, 11); //RX=pin 10, TX=pin 11
TinyGPSPlus gps;//This is the GPS object that will pretty much do all the grunt work with the NMEA data
float latitude=0; 
float longitude=0;                       
String Speed="";
int Contrast=20;
#define x A1
#define y A2
#define z A3
int xsample=0;
int ysample=0;
int zsample=0;
#define samples 10
#define minVal -50
#define MaxVal 50
void setup()
{
  Serial.begin(9600);//This opens up communications to the Serial monitor in the Arduino IDE
  serial_connection.begin(9600);//This opens up communications to the GPS 
  Serial.println("successfully Initialized....");
  Serial.println("GPS Start");//Just show to the monitor that the sketch has started
  for(int i=0;i<samples;i++)
  {
    xsample+=analogRead(x);
    ysample+=analogRead(y);
    zsample+=analogRead(z);
  }

  xsample/=samples;
  ysample/=samples;
  zsample/=samples;

  Serial.println(xsample);
  Serial.println(ysample);
  Serial.println(zsample);
  delay(1000);
}

void loop()
{
  while(serial_connection.available())//While there are characters to come from the GPS
  {
    gps.encode(serial_connection.read());//This feeds the serial NMEA data into the library one char at a time
    //Serial.println("Satellite Count:");
  }
  if(gps.location.isUpdated())//This will pretty much be fired all the time anyway but will at least reduce it to only after a package of NMEA data comes in
  {
    //Get the latest info from the gps object which it derived from the data sent by the GPS unit
    Serial.println("Satellite Count:");
    Serial.println(gps.satellites.value());
    Serial.prin tln("Latitude:");
    Serial.println(gps.location.lat(), 6);
    Serial.println("Longitude:");
    Serial.println(gps.location.lng(), 6);
    Serial.println("Speed MPH:");
    Serial.println(gps.speed.mph());
    Serial.println("Altitude Feet:");
    Serial.println(gps.altitude.feet());
    Serial.println("");
  delay(1000);
  }
   int value1=analogRead(x);
    int value2=analogRead(y);
    int value3=analogRead(z);

    int xValue=xsample-value1;
    int yValue=ysample-value2;
    int zValue=zsample-value3;
    
    Serial.print("x=");
    Serial.println(xValue);
    Serial.print("y=");
    Serial.println(yValue);
    Serial.print("z=");
    Serial.println(zValue);
  delay(1000);
  //condition for accident detection
    if(xValue < minVal || xValue > MaxVal  || yValue < minVal || yValue > MaxVal  || zValue < minVal || zValue > MaxVal)
    {//in case of accident calling to a number 5 times if needed we can add multiple numbers.
      for(int i=0;i<5;i++)
      {
      Serial.println("calling");
      GPRS.begin(9600);
      Serial.println("Connecting to network");
      delay(20000);
      Serial.println("Should be connected to network by now");
      GPRS.print("ATD+xxxxxxxxxxxx;\r");
      Serial.println("Dialing");
      delay(12000); //Give it time to connect
      //GPRS.print("ATH\r"); // And disconnect
      Serial.println("Disconnect");
      }
    }`
    delay(1000);
}
tracking_accident_locationArduino
Here, we used nodemcu, gps, gasdetector
Connecting nodemcu to wifi network and blynk app we can trace the location of person.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
static const int RXPin = 4, TXPin = 5;   // GPIO 4=D2(conneect Tx of GPS) and GPIO 5=D1(Connect Rx of GPS
static const uint32_t GPSBaud = 9600; 
char auth[] = "authentication key";              //Your Project authentication key
char ssid[] = "wifi id";                                       // Name of your network (HotSpot or Router name)
char pass[] = "wifi pwd";                                      // Corresponding Password
TinyGPSPlus gps; // The TinyGPS++ object
WidgetMap myMap(V0);
SoftwareSerial ss(RXPin, TXPin);  // The serial connection to the GPS device

BlynkTimer timer;
int gas_value;
int gas_avalue;
float spd;       //Variable  to store the speed
float sats;      //Variable to store no. of satellites response
String bearing;
unsigned int move_index = 1;   
void setup()
{
  pinMode(16, INPUT);
  Serial.begin(9600);
  ss.begin(GPSBaud);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(5000L, checkGPS); 
}
void checkGPS(){
  if (gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
      //Blynk.virtualWrite(V4, "GPS ERROR");  // Value Display widget  on V4 if GPS not detected
  }
}

void loop()
{
  gas_avalue = digitalRead(D3);
  if (gas_avalue < 1)
  {
    Serial.println("DANGER!!!!");
    digitalWrite(D4,HIGH);
    Blynk.notify("gas and smoke alert");
  }
  else
  {
    Serial.println("NO LEAKAGE");
    Blynk.notify("no leakage");
    digitalWrite(D4,LOW);
  }
  delay(100);
   while (ss.available() > 0) 
    {
      // sketch displays information every time a new sentence is correctly encoded.
      if (gps.encode(ss.read()))
        displayInfo();
  }
  Blynk.run();
  timer.run();
}
void displayInfo()
{ 

  if (gps.location.isValid() ) 
  {
    
    float latitude = (gps.location.lat());     //Storing the Lat. and Lon. 
    float longitude = (gps.location.lng()); 
    
    Serial.print("LAT:  ");
    Serial.println(latitude, 6);  // float to x decimal places
    Serial.print("LONG: ");
    Serial.println(longitude, 6);
    Blynk.virtualWrite(V1, String(latitude, 6));   
    Blynk.virtualWrite(V2, String(longitude, 6));  
    myMap.location(move_index, latitude, longitude, "GPS_Location");
    spd = gps.speed.kmph();               //get speed
       Blynk.virtualWrite(V3, spd);
       
       sats = gps.satellites.value();    //get number of satellites
       Blynk.virtualWrite(V4, sats);

       bearing = TinyGPSPlus::cardinal(gps.course.value()); // get the direction
       Blynk.virtualWrite(V5, bearing);               
      
    
  }
  

  Serial.println();
}

Schematics

Accident_detection
Uploads2ftmp2f09a60231 6c4c 4807 ace5 066186cfafed2fscreenshot2829429 delmyvblkx
gps_tracking & gas_detection
Uploads2ftmp2f79dba65f 6ed2 4a9c a549 8d0c6e2cf0732fscreenshot2829329 pmvt9d0dpl

Comments

Similar projects you might like

A fall detection system based on Arduino, Windows and Azure

Project tutorial by Jiong Shi

  • 25,076 views
  • 7 comments
  • 53 respects

GPS Tracking System with Arduino Uno and Digilent PmodGPS

Project tutorial by Ian Etheridge

  • 6,545 views
  • 1 comment
  • 25 respects

Sun Tracking Solar System

Project tutorial by Mayur_r

  • 2,677 views
  • 0 comments
  • 18 respects

Smart Garbage Monitoring System Using Arduino 101

Project tutorial by Technovation

  • 30,814 views
  • 10 comments
  • 46 respects

Bluetooth Security System

Project tutorial by Victor Carreño

  • 13,907 views
  • 2 comments
  • 36 respects
Add projectSign up / Login