MINOR BTP Report - Arduino Based Vehicle Accident Alert System Using GPS, GSM and Accelerometer
MINOR BTP Report - Arduino Based Vehicle Accident Alert System Using GPS, GSM and Accelerometer
Submitted by__
In partial fulfilment for the award of the Degree
Of
BACHELOR OF TECHNOLOGY
In
ELECTRONICS & COMMUNICATION
ENGINEERING
Page | 1
ABSTRACT
~o~o~o~
Page | 2
Chapter No. TABLE OF CONTENTS
1. TITLE
2. ABSTRACT Page No.
INTRODUCTION 4
PROCESS AND REQUIREMENT SPECIFICATION 6
3.
4. • HARDWARE REQUIREMENT 7
5. BLOCK DIAGRAM 7
11. ADVANTAGES 34
12. FUTURE SCOPE 35
13. CONCLUSION 39
BIBLIOGRAPHY 39
40
41
~o~o~o~
Page | 5
1. INTRODUCTION
~o~o~o~
Page | 4
2. PROCESS AND REQUIREMENT SPECIFICATION
HARDWARE REQUIREMENTS
S Compo Qua Specifications
l nents ntity
.
N
o
.
1 Arduino 1 _
Uno
2 GSM 1 (SIM900A)
Module
3 GPS 1 (NEO 6M)
Module
4 Accelero 1 (ADXL335)
meter
5 16x2 LCD 1 _
6 As _
Connectin
g Wires
Req
d.
7 10 K-POT 1 _
8 Breadboar _ _
d or PCB
9 1
Power
supply
12V, 1 Amp
1 1
DC motor 12V, 0.055 Amp
0
1 . Arduino Uno: -
Page | 5
Arduino is an open-source electronics platform based on easy-to-use hardware
and software. Arduino boards are able to read inputs - light on a sensor, a finger
on a button, or a Twitter message - and turn it into an output - activating a motor,
Page | 6
turning on an LED, publishing something online. You can tell your board what
to do by sending a set of instructions to the microcontroller on the board. To do
so you use the Arduino programming language (based on Wiring), and the
Arduino Software (IDE), based on Processing. Over the years Arduino has been
the brain of thousands of projects, from everyday objects to complex scientific
instruments. A worldwide community of makers - students, hobbyists, artists,
programmers, and professionals - has gathered around this open-source platform,
their contributions have added up to an incredible amount of accessible
knowledge that can be of great help to novices and experts alike. Arduino was
born at the Ivrea Interaction Design Institute as an easy tool for fast prototyping,
aimed at students without a background in electronics and programming. As
soon as it reached a wider community, the Arduino board started changing to
adapt to new needs and challenges, differentiating its offer from simple 8-bit
boards to products for IoT applications, wearable, 3D printing, and embedded
environments. All Arduino boards are completely open-source, empowering
users to build them independently and eventually adapt them to their particular
needs. The software, too, is open-source, and it is growing through the
contributions of users worldwide.
2. GSM Module: -
Page | 7
GSM/GPRS module is used to establish communication between a computer and
a GSM-GPRS system. Global System for Mobile communication (GSM) is an
architecture used for mobile communication in most of the countries.
AT Command:
Page | 8
3. GPS Module: -
GPS stands for Global Positioning System and used to detect the Latitude and
Longitude of any location on the Earth, with exact UTC time (Universal Time
Coordinated). GPS module is used to track the location of accident in our
project. This device receives the coordinates from the satellite for each and every
second, with time and date. We have previously extracted $GPGGA string in
Vehicle Tracking System to find the Latitude and Longitude
Coordinates.
GPS module sends the data related to tracking position in real time, and it sends
so many data in NMEA format (see the screenshot below). NMEA format
consists several sentences, in which we only need one sentence. This sentence
starts from $GPGGA and contains the coordinates, time and other useful
information. This GPGGA is referred to Global Positioning System Fix Data.
Page | 9
We can extract coordinate from $GPGGA string by counting the commas in the
string. Suppose you find $GPGGA string and stores it in an array, then Latitude
can be found after two commas and Longitude can be found after four commas.
$GPGGA,HHMMSS.SSS,latitude,N,longitude,E,FQ,NOS,HDP,altitude,M,height,M,,checksum
data
Identifier Description
Longitude Longitude(Coordinate)
Page | 10
Altitude Altitude (meters above from sea level)
M Meter
Height Height
4. Accelerometer: -
The ADXL335 is a small, thin, low power, complete 3-axis accelerometer with
signal conditioned voltage outputs. The product measures acceleration with a
Page | 11
minimum full-scale range of ±3 g. It can measure the static acceleration of
gravity in tilt-sensing applications, as well as dynamic acceleration resulting
from motion, shock, or vibration.
5. 16 x 2 LCD Display: -
Page | 12
LCD stands for liquid crystal display. Character and graphical LCD’s are most
common among hobbyist and DIY electronic circuit/project makers. Since their
interface serial/parallel pins are defined so it’s easy to interface them with many
microcontrollers. They are used to show status of the product or provide
interface for inputting or selecting some process. Character LCD come in many
sizes 8x1, 8x2, 10x2, 16x1, 16x2, 16x4, 20x2, 20x4, 24x2, 30x2, 32x2, 40x2 etc.
We have used 16x2 LCD for our project.
Page | 13
7. DC Motor: -
DC motors were the first form of motor widely used, as they could be powered
from existing direct-current lighting power distribution systems. A DC motor's
speed can be controlled over a wide range, using either a variable supply voltage
or by changing the strength of current in its field windings. Small DC motors are
used in tools, toys, and appliances. The universal motor can operate on direct
current but is a lightweight brushed motor used for portable power tools and
appliances. Larger DC motors are currently used in propulsion of electric
vehicles, elevator and hoists, and in drives for steel rolling mills. The advent of
power electronics has made replacement of DC motors with AC motors possible
in many applications.
Page | 14
8. Printed Circuit Board: -
Printed circuit boards are used in all but the simplest electronic products. They
are also used in some electrical products, such as passive switches.
~o~o~o~
3. BLOCK DIAGRAM
Page | 15
4. BLOCK DIAGRAM EXPLANATION
In this project, Arduino is used for controlling whole the process with a
GPS Receiver and GSM module. GPS Receiver is used for detecting
coordinates of the vehicle, GSM module is used for sending the alert SMS with
the coordinates and the link to Google Map. Accelerometer namely ADXL335
is used for detecting accident or sudden change in any axis. And an optional
16x2 LCD is also used for displaying status messages or coordinates. We have
used GPS Module Neo 6M and GSM Module SIM900A.
When we are ready with our hardware after programming, we can install it
in our vehicle and power it up. Now whenever there is an accident, the car gets
tilt and accelerometer changes his axis values. These values read by Arduino and
Page | 16
checks if any change occurs in any axis. If any change occurs then Arduino reads
coordinates by extracting $GPGGA String from GPS module data (GPS working
explained above) and send SMS to the predefined number to the police or
ambulance or family member with the location coordinates of accident place.
The message also contains a Google Map link to the accident location, so that
location can be easily tracked. When we receive the message then we only need
to click the link and we will redirect to the Google map and then we can see the
exact location of the vehicle. Speed of Vehicle, in knots (KPH), is also sent in
the SMS and displayed on the LCD panel.
#define MaxVal 50
~o~o~o~
5. CIRCUIT DIAGRAM
Page | 17
Fig: Circuit Diagram of Accident Alert System.
Page | 18
6. HARDWARE IMPLEMENTATION
Complete Program has been given below in Code section; here we are
explaining its various functions in brief.
Page | 19
Page | 20
First we have included all the required libraries or headers files and declared
various variables for calculations and storing data temporary.
After this, we have created a function void initModule(String cmd, char *res,
int t) to initialize the GSM module and checking its response using AT
commands.
{ while(1
Serial.println(cmd);
Serial1.println(cmd);
delay(100);
while(Serial1.available()>0)
{ if(Serial1.find(res))
Serial.println(res);
delay(t); return; }
else
Serial.println("Error");
After this, in void setup() function, we have initialized hardware and software
} }
delay(t);
void setup()
Serial1.begin(9600);
Serial.begin(9600);
lcd.begin(16,2);
lcd.print("Accident Alert
");
");
lcd.setCursor(0,1);
lcd.print(" System
delay(2000);
lcd.clear(); ...
. ......
lcd.print("Callibrating ");
lcd.setCursor(0,1);
Page | 22
lcd.print("Acceleromiter");
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);
After this, in the void loop() function, we have read accelerometer axis values
and done a calculation to extract changes with the help of samples that are taken
in Calibration. Now if any changes are more or less then defined level then
Arduino sends a message to the predefined number.
void loop()
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);
..... .....
........ ...
Here we have also created some other function for various purposes like void
gpsEvent() to get GPS coordinates, void coordinate2dec() for extracting
coordinates from the GPS string and convert them into Decimal values, void
show_coordinate() for displaying values over serial monitor and LCD, and
finally the void Send() for sending alert SMS to the predefined number.
Programming: -
#include<SoftwareSerial.h>
SoftwareSerial Serial1(2,3); //make RX arduino line is pin 2, make
TX arduino line is pin 3.
SoftwareSerial gps(4,5);
#include<LiquidCrystal.h>
LiquidCrystal lcd(8,9,10,11,12,13);
#define x A2
#define y A1
#define z A0
Page | 24
int xsample=0;
int ysample=0;
int zsample=0;
#define buzzerAlert 6 // Buzzer Alert OFF
#define engineMotor 7 // Engine Motor ON
#define samples 10
else
{
Serial.println("Error");
}
}
delay(t);
}
}
void setup()
{
pinMode(engineMotor, OUTPUT);
pinMode(buzzerAlert, OUTPUT);
digitalWrite(engineMotor, LOW); // ON
digitalWrite(buzzerAlert, HIGH); // OFF
Serial1.begin(9600);
Serial.begin(9600);
Page | 25
lcd.begin(16,2); lcd.print("
Smart Accident ");
lcd.setCursor(0,1);
lcd.print(" Alert System ");
delay(3000); lcd.clear();
lcd.print("Initializing");
lcd.setCursor(0,1);
lcd.print("Please
Wait..."); delay(1000);
Serial.println("Initializing....");
initModule("AT","OK",1000);
initModule("ATE1","OK",1000);
initModule("AT+CPIN?","READY",1000);
initModule("AT+CMGF=1","OK",1000);
initModule("AT+CNMI=2,2,0,0,0","OK",1000);
Serial.println("Initialized
Successfully"); lcd.clear();
lcd.print("Initialized");
lcd.setCursor(0,1);
lcd.print("Successfully"); delay(2000);
lcd.clear(); lcd.print("Calibrating ");
lcd.setCursor(0,1);
lcd.print("Accelerometer"); 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);
lcd.clear();
lcd.print("Waiting For GPS");
lcd.setCursor(0,1);
lcd.print(" Signal ");
delay(2000);
gps.begin(9600);
get_gps();
show_coordinate();
delay(2000); lcd.clear();
Page | 26
lcd.print("GPS is
Ready");
delay(1000);
lcd.clear();
lcd.print("System Ready");
Serial.println("System Ready..");
}
void loop()
{ 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);
Page | 27
Serial.println("Sending SMS"); // Engine Motor ON
delay(2000); // Buzzer Alert OFF
Send();
lcd.clear();
lcd.print("SMS Sent");
Serial.println("SMS Sent");
delay(2000);
}
else
{ digitalWrite(engineMotor, LOW);
digitalWrite(buzzerAlert, HIGH);
lcd.clear();
lcd.print("System Ready");
delay(2000); //Serial incoming data from
}
}
void gpsEvent()
{ gpsString=""; //store incoming data
while(1)
{ while
(gps.available()>0)
GPS
{ char inChar =
//check for right
(char)gps.read(); gpsString+=
inChar;
from GPS to temparary string str[] i+
+;
Serial.print(inChar);
if (i < 7)
{ if(gpsString[i-1] != test[i-1])
string
{ i=0;
gpsString="";
}
}
if(inChar=='\r')
{ if(i>60
)
{ gps_status=1;
break; } else
Page | 28
Page | 29
{ i=0;
}
}
}
if(gps_status)
break;
}
}
void get_gps()
{ lcd.clear();
lcd.print("Getting GPS Data");
lcd.setCursor(0,1);
lcd.print("Please Wait.....");
delay(2000); gps_status=0; int
x=0; while(gps_status==0)
{ gpsEvent(); int
str_lenth=i;
coordinate2dec();
i=0;x=0;
str_lenth=0;
}
}
void show_coordinate()
{ lcd.clear();
lcd.print("Lat:");
lcd.print(latitude);
lcd.setCursor(0,1);
lcd.print("Log:");
lcd.print(logitude);
Serial.print("Latitude:");
Serial.println(latitude);
Serial.print("Longitude:");
Serial.println(logitude);
Serial.print("Speed(in knots)=");
Serial.println(Speed);
delay(2000); lcd.clear();
lcd.print("Speed(Knots):");
lcd.setCursor(0,1);
lcd.print(Speed);
}
void coordinate2dec()
{
String lat_degree="";
for(i=19;i<=20;i++)
lat_degree+=gpsString[i];
String lat_minut="";
for(i=21;i<=28;i++)
lat_minut+=gpsString[i];
Page | 30
String log_degree="";
for(i=32;i<=34;i++)
log_degree+=gpsString[i];
String log_minut="";
for(i=35;i<=42;i++)
log_minut+=gpsString[i];
Speed="";
for(i=46;i<=49;i++) //extract longitude from string
Speed+=gpsString[i];
minut= log_minut.toFloat();
minut=minut/60;
degree=log_degree.toFloat();
logitude=degree+minut;
}
void Send()
{
Serial1.println("AT");
delay(500);
serialPrint();
Serial1.println("AT+CMGF=1");
delay(500); serialPrint();
Serial1.print("AT+CMGS=");
Serial1.print('"');
Serial1.print("7205159093"); //mobile no. for SMS alert
Serial1.println('"');
delay(500); serialPrint();
Serial1.println("Accident Detected! ");
Serial1.print("Latitude:");
Serial1.println(latitude);
delay(500); serialPrint();
Serial1.print(" longitude:");
Serial1.println(logitude);
delay(500); serialPrint();
Serial1.print(" Speed:");
Serial1.print(Speed);
Serial1.println("Knots")
; delay(500);
serialPrint();
Serial1.print("http://maps.google.com/maps?&z=15&mrt=yp&t=k&q=");
Serial1.print(latitude,6);
Serial1.print("+"); //28.612953, 77.231545
//28.612953,77.2293563
Page | 31
Serial1.print(logitude,6);
Serial1.write(26);
delay(2000);
serialPrint();
}
void serialPrint()
{ while(Serial1.available()>0)
{
Serial.print(Serial1.read());
}
}
~o~o~o~
8. FLOW CHART
START
Page | 32
CHECK CONNECTIVITY AND
RESPONSE OF SENSORS
No
ACCIDENT
OCCURS?
Yes
No Yes
FALSE
ALARM?
• So overall, the flow chart starts with checking the connectivity and
response of all the sensors.
• Now when the vehicle starts, all the sensors will be activated and these
sensors will be observing for any accidents to occur.
Page | 33
• If sensors detect accident, it will first check whether accident really
occurred or it is a false alarm.
• If the alarm is false, then the sensors will continue to observe for any kind
of accidents.
• Now if an accident is detected then the sensors will trigger an alarm and
GSM module will send message to the rescue team.
• The message that is sent will contain all the information about the
accident like location, co-ordinates, speed of the vehicle and a Google
map link of the location of the accident.
~o~o~o~
9. OUTPUT
• In this below figure, when the vehicle starts, all the sensors starts to calibrate
themselves. When these sensors are calibrated and the connectivity and
response of all sensors are good then our vehicle alert system will become
ready.
• The figure shows that our system is ready-
Page | 34
• In this below figure it can be seen that the system is
calibrating the accelerometer-
Page | 35
• After the initialization, it looks for the co-ordinates of the place –
Page | 36
• After getting the location, it looks for the speed in knots-
• After the accident is detected, the device sends message to that mobile phone
whose number is registered in our device –
Page | 37
~o~o~o~
10. ADVANTAGES
Page | 38
A wireless webcam can be added in this for capturing the images which will
help in providing driver`s assistance. This can also be bettered by locking all the
brakes automatically in case of accident. Mostly in accidents, it becomes serious
as the drivers lose control and fail to stop the vehicle. In such cases, the
vibration sensor will be triggered because of the vibrations received and also
processed by the processor. The processor has to be linked to the devices which
can lock the brakes when triggered. With this improvement, we can stop the
vehicle and can weaken the impact of the accident. This system can also be
utilized in fleet management, food services, traffic violation cases, rental vehicle
services etc.
~o~o~o~
12. CONCLUSION
Our idea is used to detect accident and automate emergency assistance services.
As a result, system is sending SMS to the nearest Emergency assistance service
provider from accident location. The high demand of automobiles has also
increased the traffic hazards and the road accidents. Life of the people is under
high risk. This is because of the lack of best emergency facilities available in
our country. An automatic alarm device for vehicle accidents. This design is a
system which can detect accidents in significantly less time and sends the basic
information. This alert message is sent to the rescue team in a short time, which
will help in saving the valuable lives. A Switch is also provided in order to
terminate the sending of a message in rare case where there is no casualty, this
can save the precious time of the medical rescue team. When the accident occurs
the alert message is sent automatically to the rescue team and to the police
station and the message is sent through the GSM module
~o~o~o~
Page | 39
13. BIBLIOGRAPHY
• https://circuitdigest.com/sites/default/files/inlineimages/Arduino-Vehicle-
Accident-Alert-System-with-GPS-GSM-and-Accelerometer.jpg
• http://ijitee.org/wp-content/uploads/papers/v8i4s2/D1S0048028419.pdf
• https://www.hackster.io/TechnicalEngineer/accident-detection-
andmessaging-system-using-gsm-and-gps-21fb76
• https://www.analog.com/media/en/technical-documentation/datasheets/
ADXL335.pdf
• https://www.sparkpcb.com/images/watermarked/1/detailed/2/NEO-
6M_GPS_Module.jpg
• https://cdnmedia.itead.cc/media/catalog/product/cache/1/image/
9df78eab33525d08d
6e5fb8d27136e95/i/m/im120525010_8_1.jpg
Page | 40