Professional Documents
Culture Documents
Vehicle Accident Alert System Using GSM and Gps
Vehicle Accident Alert System Using GSM and Gps
Vehicle Accident Alert System Using GSM and Gps
Submitted To
THE INSTITUTION OF ENGINEERS (INDIA)
Done By
ARSHID SHYAMKUMAR
ESTABLISHED 1920
ESTABLISHED 1920
CERTIFICATE
Date :
(India) for the award of degree of AMIE ECE department in Winter 2015
session. The results embodied in this thesis have not been submitted to any
Project Guide
Mr. B.KOTESWAR RAO FIE
DECLARATION
work is an original one and has not been submitted earlier to any other institution for
Place : Hyderabad,
Date:
ARSHID SHYAMKUAR
ACKNOWLEDGEMENT
obligation to Mr. B.KOTESWAR RAO.,FIE, Project guide for his constant support,
support and co operation of the people. I would like to express my deep gratitude
ARSHID SHYAMKUMAR
ST-607777-9
TABLE OF CONTENTS
SYNOPSIS
……………………………………………………………………………………………………………
…………………….1-3
ACTIVITY REPORT
……………………………………………………………………………………………………………
…………4-5
LIST OF FIGURES
……………………………………………………………………………………………………………
……………6
1.INTRODUCTION
……………………………………………………………………………………………………………
…………7
2.BLOCK DIAGRAM
……………………………………………………………………………………………………………
……….8
3.HARDWARE
……………………………………………………………………………………………………………
……………….11
3.1 MICROCONTROLLER
……………………………………………………………………………………………………………
12-19
3.2 GPS
……………………………………………………………………………………………………………
…………………………20
3.3 GSM
……………………………………………………………………………………………………………
…………………………21-26
6. RESULTS …………………………………..
………………………………………………………………………………………………..42
9. BIBILOGRAPHY
……………………………………………………………………………………………………………
………………45
SYNOPSIS
The project titled as VEHICLE ACCIDENT ALERT SYSTEM USING GSM AND
GPS is an embedded based system. By this advanced technology we can get accurate
information about the collision and short circuit taken place in the vehicle. This system
combines advanced hardware design and sophisticated electronic control technology into a
compact, reliable package.
In this project a vibration sensor is used as an accident detector. When the vehicle
meets with an accident, the vibrating sensors generate the signal, this signal is being
compared with the threshold values. If the value generated exceeds the threshold it is
recognized as accident and this information is immediately informed to their relative persons
through GSM as a message to mobile.
In this system vibration sensors are used for detecting range of collision, Similarly the
short circuit sensors will detect the short circuited condition and intimated through the sms in
which disaster can be minimized. Vibration Sensors data will be in analog form so it needs to
be converted to digital, which is fulfilled through A/D Converter, and this digital data is being
sent to microcontroller there it is compared with the threshold values, if it exceeds the
threshold values then only data will be sent to GSM (global system for mobile
communication) & location data is captured with the help of GPS (Global Positioning
System). Here we are making use of the GPS which gives exact location of the collide
vehicle.
1
Importance of the study:
In present days as population increases the number of vehicles also increases. This
results in more accidents and deaths and also theft. The result of this system saves death or
reduces the death rates, by providing information about the accident to the Monitoring system
immediately. It improves the level of management in buses of travel agencies and cargo
transportation vehicles, such as trucks.It also provides security to personal vehicles like car by
locking the vehicle engine from remote location using GSM in case of theft .A Monitoring
system continuously waits for information sent from vehicle system. The information sent by
the vehicle system includes position of a vehicle (Longitude and Latitude), speed and
temperature. The information provided to the Monitoring system when accident happens or
when user accesses the system to get the information about the vehicle
Methodology to be used for carrying out the study:
◆ Understand the architecture of AT 895S2 Micro controller and operations of GSM and
GPS Modules.
◆ Using MEMS, generate different values to test the behavior of the system.
◆ Observe the Alert info in LCD Modules for different values and finalize the correct
◆ Get the Alert information on SMS on Vehicle collision and Short circuit.
Equipment/Tools required:
No. From / To
22/01/2016
9 Demonstration of project 2 to
23/01/2016
Submission of project
10 report. 1 25/01/2016
Activity Report
Approval by Project guide
There are more and more traffic jams as vehicle’s demands are getting high day by day. So,
transportation needs more improvement as demands are increasing there will be more possibility
of vehicle accidents . Vehicle accidents are one of the leading causes of the fatalities. It will be a
serious consequence if people can’t get help on right time. Poor emergency incident is a major
cause of death rate in our country . Even with awareness campaign, this problem is still rising
due to riders drunk driving and speed driving. Major automobile manufacturers have developed
safety devices such as seat belt to protect riders from accidental injuries . Life saving measure
electronic stability control also reduces injuries. Crash analysis studies have shown, traffic
accidents could have been prevented with the use of this advanced life saving measure . This
design focuses on providing basic information on the accident site to the hospital or police
station. As s result of this sudden help, public life may get save
In this work, ADXL accelerometer, a three-axis accelerometer and GPS tracking system works
for accidental monitoring. This design detects accidents in less time and sends this information
to the hospitals. In this case GSM will send short message to the hospital or police station. This
message will read the geographical co-ordinates of accident spot with the help of GPS. And, as
now the location has been traced by the GPS, emergency medical service can be given to the
accident victims as soon as possible. Using this method, traffic fatalities can be reduced as time
between when accident occurs and responders are dispatched to the accident scene, reduces.
Accelerometer sensor embedded in a car determines severity of the accident as how much car
has rolled
As soon as the accident occurs, an alert message including latitude, longitude position, date and
time of accident occurrence and finally link, indicating Google map is sent automatically to the
rescue team or
to the police station. This message is sent with the help of the GSM module and accident
location is detected through GPS module. The accident can be recognized precisely with the help
of ADXL accelerometer sensor which also acts as vibration sensor. . This design provides
solution to the road accidents in most feasible way.
2. BLOCK DIAGRAM
This is the block diagram of vehicle accident alert system. This shows the overall view of the
vehicle accident alert system circuit. The blocks connected here are LCD display, GPS, GSM,
MEMS, Power supply , short circuit detector.
Power supply
This vehicle accident alert system takes input from GPS and send it through the GSM module
to desired mobile using mobile communication when accident or short circuit occurs. As soon
as accident occurs, Controller takes the Lat and Long values and sends the alert to the mobile
using SMS. This alert will help others to track the vehicle and rescue people in it.
3. HARDWARE
For designing this hardware many types of devices are used to make it perfectly working. All
the devices are purchased from different manufacturers. These components are soldered on a
soldering board. The following list of hardware are required for this system.
GSM MODULE
A/D CONVERTER
S ACCELEROMETER
GPS MODULE
A SWITCH FOR SHORT CIRCUIT SYSTEM
MICRO CONTROLLER AT89S52
MAX232
RS232
LCD DISPLAY
POWER SUPPLY
CRYSTAL OSCILLATOR
LM7805
BRIDGE RECTIFIER
LED
RESET BUTTON
3.1 Microcontroller
Here in this system micro controller used is AT89S52. Mainly micro controller consists of cpu,
memory and various I/O pins, and the speed of this micro controller is enough to execute the
program in real time. This particular micro controller is chosen because the experiment
requires minimum of 8-bit micro controller. This microcontroller contains 4Kb flash memory
inbuilt in it, this memory is enough to dump our code in to the microcontroller. This micro
controller contains 40 pins and circuit is designed according to fig 2.3. The 40 pins of
microcontroller has different properties and usage they are shown in the following image.
Features:
• 3 16-bit Timer/Counters
• Watchdog Timer
• Power-off Flag
DESCRIPTION OF MICROCONTROLLER 89S52:
VCC
Supply voltage.
GND
Ground.
Port 0
Port 1
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1
Output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins,
they are pulled high by the internal pull-ups and can be used as inputs. In
addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count
input
Port 2
Port 3
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3
output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins,
they are pulled high by the internal pull-ups and can be used as inputs. As inputs,
Port 3 pins that are externally being pulled low will source current (IIL) because of
the pull-ups. Port 3 also serves the functions of various special features of the
AT89S52, as shown in the following table.
And verification.
RST
Reset input. A high on this pin for two machine cycles while the
oscillator is running resets the device.
ALE/PROG
Address Latch Enable (ALE) is an output pulse for latching the low byte of the
address during accesses to external memory. This pin is also the program pulse
input (PROG) during Flash programming. In normal operation, ALE is emitted at a
constant rate of1/6 the oscillator frequency and may be used for external timing
or clocking purposes. Note, however, that one ALE pulse is skipped during each
access to external data Memory. If desired, ALE operation can be disabled by
setting bit 0 of SFR location
8EH. With the bit set, ALE is active only during a MOVX or MOVC
instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-
disable bit has no effect if the micro controller is in external execution
mode.
PSEN
EA/VPP
Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
XTAL2
Oscillator Characteristics
The “R” registers: The “R” registers are a set of eight registers that
are named R0, R1. Etc up to R7. These registers are used as auxiliary
registers in many operations.
The Data Pointer: The Data pointer (DPTR) is the 8051’s only user
accessible 16-bit (2Bytes) register. The accumulator, “R” registers are
all 1-Byte values. DPTR, as the name suggests, is used to point to data.
It is used by a number of commands, which allow the 8051 to access
external memory.
ADDRESSING MODES:
An “addressing mode” refers that you are addressing a given
memory location. In summary, the addressing modes are as follows,
with an example of each:
Indexed Addressing
GPS abbreviates global positioning system and this is used to detect the latitude and longitude of
the particular position and it also shows the exact time. It detects these values anywhere on the
earth. In our project it plays main role and it is the main source of the latitude and longitude of
the vehicle to know the accident occurred location.This gadget gets the coordinates from the
satellite for each and every second. This device is the main component of vehicle project.
GSM abbreviates global system for mobile communication, this is a second generation (2G)
mobile network. This is widely used in all over the world for mobile communication. This GSM
device consists of sim slot in which a sim can be inserted which has a unique number, this
unique number is used for contact. This GSM device consists a unique number called imei
number and this is different for each and every hardware kit. In our project the device is used for
transmitting data. The data from GPS is transmitted to given mobile through this GSM itself.
The rarer 400 and 450 MHz frequency bands are assigned in some countries, where these frequencies
were previously used for first-generation systems.
GSM-900 uses 890–915 MHz to send information from the mobile station to the base station (uplink) and
935–960 MHz for the other direction (downlink), providing 124 RF channels (channel numbers 1 to 124)
spaced at 200 kHz. Duplex spacing of 45 MHz is used. In some countries the GSM-900 band has been
extended to cover a larger frequency range. This 'extended GSM', E-GSM, uses 880–915 MHz (uplink)
and 925–960 MHz (downlink), adding 50 channels (channel numbers 975 to 1023 and 0) to the original
GSM-900 band. Time division multiplexing is used to allow eight full-rate or sixteen half-rate speech
channels per radio frequency channel. There are eight radio timeslots (giving eight burst periods) grouped
into what is called a TDMA frame. Half rate channels use alternate frames in the same timeslot. The
channel data rate is 270.833 kbit/s, and the frame duration is 4.615 ms.
GSM Advantages:
GSM also pioneered a low-cost, to the network carrier, alternative to voice calls, the Short t message
service (SMS, also called "text messaging"), which is now supported on other mobile standards as well.
Another advantage is that the standard includes one worldwide Emergency telephone number, 112. This
makes it easier for international travelers to connect to emergency services without knowing the local
emergency number.
GSM provides recommendations, not requirements. The GSM specifications define the functions and
interface requirements in detail but do not address the hardware. The GSM network is divided into three
major systems: the switching system (SS), the base station system (BSS), and the operation and support
system (OSS).
The Switching System:
The switching system (SS) is responsible for performing call processing and subscriber-related functions.
The switching system includes the following functional units.
Home location register (HLR): The HLR is a database used for storage and management of
subscriptions. The HLR is considered the most important database, as it stores permanent data
about subscribers, including a subscriber's service profile, location information, and activity
status. When an individual buys a subscription from one of the PCS operators, he or she is
registered in the HLR of that operator.
Mobile services switching center (MSC): The MSC performs the telephony switching functions
of the system. It controls calls to and from other telephone and data systems. It also performs
such functions as toll ticketing, network interfacing, common channel signaling, and others.
Visitor location register (VLR): The VLR is a database that contains temporary information
about subscribers that is needed by the MSC in order to service visiting subscribers. The VLR is
always integrated with the MSC. When a mobile station roams into a new MSC area, the VLR
connected to that MSC will request data about the mobile station from the HLR. Later, if the
mobile station makes a call, the VLR will have the information needed for call setup without
having to interrogate the HLR each time.
Authentication center (AUC): A unit called the AUC provides authentication and encryption
parameters that verify the user's identity and ensure the confidentiality of each call. The AUC
protects network operators from different types of fraud found in today's cellular world.
Equipment identity register (EIR): The EIR is a database that contains information about the
identity of mobile equipment that prevents calls from stolen, unauthorized, or defective mobile
stations. The AUC and EIR are implemented as stand-alone nodes or as a combined AUC/EIR
node.
All radio-related functions are performed in the BSS, which consists of base station controllers (BSCs)
and the base transceiver stations (BTSs).
BSC: The BSC provides all the control functions and physical links between the MSC and BTS.
It is a high-capacity switch that provides functions such as handover, cell configuration data, and
control of radio frequency (RF) power levels in base transceiver stations. A number of BSCs are
served by an MSC.
BTS: The BTS handles the radio interface to the mobile station. The BTS is the radio equipment
(transceivers and antennas) needed to service each cell in the network. A group of BTSs are
controlled by a BSC.
GSM Specifications:
Specifications for different personal communication services (PCS) systems vary among the different
PCS networks. Listed below is a description of the specifications and characteristics for GSM.
Frequency band: The frequency range specified for GSM is 1,850 to 1,990 MHz (mobile
station to base station).
Duplex distance: The duplex distance is 80 MHz. Duplex distance is the distance between the
uplink and downlink frequencies. A channel has two frequencies, 80 MHz apart.
Channel separation: The separation between adjacent carrier frequencies. In GSM, this is 200
kHz.
Transmission rate: GSM is a digital system with an over-the-air bit rate of 270 kbps.
Access method: GSM utilizes the time division multiple access (TDMA) concept. TDMA is a
technique in which several different calls may share the same carrier. Each call is assigned a
particular time slot.
Speech coder: GSM uses linear predictive coding (LPC). The purpose of LPC is to reduce the
bit rate. The LPC provides parameters for a filter that mimics the vocal tract. The signal passes
through this filter, leaving behind a residual signal. Speech is encoded at 13 kbps.
Main AT commands:
"AT command set for GSM Mobile Equipment” describes the Main AT commands to communicate via a
serial interface with the GSM subsystem of the phone.
AT commands are instructions used to control a modem. AT is the abbreviation of Attention. Every
command line starts with "AT" or "at". That's why modem commands are called AT commands. Many of
the commands that are used to control wired dial-up modems, such as ATD (Dial), ATA (Answer), ATH
(Hook control) and ATO (Return to online data state), are also supported by GSM/GPRS modems and
mobile phones. Besides this common AT command set, GSM/GPRS modems and mobile phones support
an AT command set that is specific to the GSM technology, which includes SMS-related commands like
AT+CMGS (Send SMS message), AT+CMSS (Send SMS message from storage), AT+CMGL (List SMS
messages) and AT+CMGR (Read SMS messages).
Note that the starting "AT" is the prefix that informs the modem about the start of a command line. It is
not part of the AT command name. For example, D is the actual AT command name in ATD and +CMGS
is the actual AT command name in AT+CMGS. However, some books and web sites use them
interchangeably as the name of an AT command.
Here are some of the tasks that can be done using AT commands with a GSM/GPRS modem or mobile
phone:
Get basic information about the mobile phone or GSM/GPRS modem. For example, name of
manufacturer (AT+CGMI), model number (AT+CGMM), IMEI number (International Mobile
Equipment Identity) (AT+CGSN) and software version (AT+CGMR).
Get basic information about the subscriber. For example, MSISDN (AT+CNUM) and IMSI
number (International Mobile Subscriber Identity) (AT+CIMI).
Get the current status of the mobile phone or GSM/GPRS modem. For example, mobile phone
activity status (AT+CPAS), mobile network registration status (AT+CREG), radio signal strength
(AT+CSQ), battery charge level and battery charging status (AT+CBC).
Establish a data connection or voice connection to a remote modem (ATD, ATA, etc).
Perform security-related tasks, such as opening or closing facility locks (AT+CLCK), checking
whether a facility is locked (AT+CLCK) and changing passwords (AT+CPWD).
(Facility lock examples: SIM lock [a password must be given to the SIM card every time the
mobile phone is switched on] and PH-SIM lock [a certain SIM card is associated with the mobile
phone. To use other SIM cards with the mobile phone, a password must be entered.])
Control the presentation of result codes / error messages of AT commands. For example, you can
control whether to enable certain error messages (AT+CMEE) and whether error messages should
be displayed in numeric format or verbose format (AT+CMEE=1 or AT+CMEE=2).
Get or change the configurations of the mobile phone or GSM/GPRS modem. For example,
change the GSM network (AT+COPS), bearer service type (AT+CBST), radio link protocol
parameters (AT+CRLP), SMS center address (AT+CSCA) and storage of SMS messages
(AT+CPMS).
Save and restore configurations of the mobile phone or GSM/GPRS modem. For example, save
(AT+CSAS) and restore (AT+CRES) settings related to SMS messaging such as the SMS center
address.
3.4 MEMS Accelerometer sensor
MEMS (Micro-Electro Mechanical System)-based accelerometers are devices that measure the
proper acceleration. In relativity theory, proper acceleration is the physical acceleration
experienced by an object. The psychical acceleration is measurable by sensors. These sensors
are part of the sensing cluster of ubiquitous technologies. Sensing technologies make use of
physical parameters from the environment, such as temperature, pressure, force and light. An
accelerometer measures weight per unit of mass, a quantity also known as specific force, or g-
force.
MEMS-based accelerometers are one of the simplest but also most applicable micro-
electromechanical devices. They are widely used in cost sensitive, low power, motion- and tilt-
sensing applications like mobile devices, gaming systems, disk drive protection, image
stabilization and sports and health devices.
3.5 Liquid crystal display
LCD is the display device which is of 16x2 size and it has yellow background light. This LCD is
connected to microcontroller. The following is the interfacing diagram of LCD with
microcontroller AT89S52.
A liquid crystal display (LCD) is a thin, flat display device made up of any
number of color or monochrome pixels arrayed in front of a light source or reflector. Each pixel
consists of a column of liquid crystal molecules suspended between two transparent electrodes,
and two polarizing filters, the axes of polarity of which are perpendicular to each other. Without
the liquid crystals between them, light passing through one would be blocked by the other. The
liquid crystal twists the polarization of light entering one filter to allow it to pass through the
other.
A program must interact with the outside world using input and output devices
that communicate directly with a human being. One of the most common devices attached to an
controller is an LCD display. Some of the most common LCDs connected to the contollers are
16X1, 16x2 and 20x2 displays. This means 16 characters per line by 1 line 16 characters per line
by 2 lines and 20 characters per line by 2 lines, respectively.
Figure 8 LCD interfacing with AT89S52
To enable terminal latch of LCD high to low pulse is sent and RS bit is enabled. Once the latch
is enabled the data is transferred through the interfacing pins parallel and the LCD shows the
display on it. These LCD are easy to program and they are economical too. LCD interfacing
with microcontroller is very easy. Here in our vehicle tracking project LCD displays the output
i.e. latitude and longitude of the vehicle. The following figure shows the LCD display of
latitude and longitude.
For Short circuit detection, we are shorting two terminals which is connected to one of the
pins in the controller. Once short circuit is detected in this port controller then takes input
from GPS and which goes into rs232. This Rs232 sends data into max232 and it converts the
data format and sends it to the Rx (receiver pin) of microcontroller and this microcontroller
stores this data in USART buffer and the data stored is sent again through Tx pin into max232
this max 232 sends the data into GSM via rs232. This is how vehicle short circuit alert works
using GSM and GPS. The lcd interfaced to the microcontroller also shows the display of the
coordinates. This lcd display is only used to know the working condition of the vehicle
tracking system.
#include <reg52.h>
#include<string.h>
#include<stdio.h>
#include<intrins.h>
#define BUFF_LEN 50
#define lcd P2
/////////////////////////////////////
sbit CLK = P3^6;
sbit DOUT= P3^5;
sbit DIN = P3^4;
sbit CS = P3^7;
sbit mtr =P1^2;
sbit sw = P1^0;
sbit rl=P1^1;
//////////////////////////////
void init_lcd(void);
void cmd_lcd(unsigned char);
void lcd_data(unsigned char);
void display_lcd(unsigned char *);
float adc_convert1 (void);
void integer_lcd(int);
void delay_ms(unsigned int);
int f,f1,x,y;
/////////////////////////////////////////////////////////
void main (void)
{
TMOD = 0x20;
SCON = 0x50;
TH1 = 0xFD;
TR1 = 1;
rl=0;
init_lcd();
GSM_INIT();
cmd_lcd(0x80);
display_lcd("COLLISION AND ");
cmd_lcd(0xc0);
display_lcd("SHORT CIRCUIT ");
delay_ms(500);
cmd_lcd(0x01);
cmd_lcd(0x80);
display_lcd("ALERT INFO... ");
cmd_lcd(0xc0);
display_lcd(" IN VEHICLES ");
delay_ms(500);
cmd_lcd(0x01);
cmd_lcd(0x80);
display_lcd("USING GPS &GSM ");
cmd_lcd(0xc0);
display_lcd("TECHNOLOGIES...");
cmd_lcd(0x01);
cmd_lcd(0x01);
cmd_lcd(0x80);
display_lcd("X-: Y-: ");
mtr=0;
sw=1;
IE = 0x90;
while(1)
{
mtr=0;
channel=0;
channel1=1;
f=adc_convert();
x=f;
cmd_lcd(0x83);
integer_lcd(f);
delay_ms(500);
/************************/
f=adc_convert1();
y=f;
// f=f/4;
cmd_lcd(0x8B);
integer_lcd(f);
delay_ms(500);
if(sw==0)
{
cmd_lcd(0xC0);
display_lcd("SHORT CKT OCCURED ");
mtr=1;
rl=1;
RECEIVE_GPGLL(1000);
cmd_lcd(0x01);
RECEIVE_GPS();
rl=0;
delay_ms(500);
cmd_lcd(0x01);
SEND_STR("AT");
SEND_CHR(0x0D);
delay_ms(500);
SEND_STR("AT+CMGF=1");
SEND_CHR(0x0D);
delay_ms(500);
display_lcd("SENDING SMS...");
SEND_STR("AT+CMGS=");
SEND_CHR('"');
SEND_STR("9948900106");
SEND_CHR('"');
delay_ms(500);
SEND_CHR(0x0D);
delay_ms(500);
SEND_STR("\r\n");
SEND_STR("SHORT CKT OCCURED AT");
SEND_STR("\r\n");
delay_ms(500);
i=1;
while((REC_BUFF[i++]!=',')||(j++<1));
j=0;
SEND_STR("LT:");
while((REC_BUFF[i]!=',')||(j++<1))
SEND_CHR(REC_BUFF[i++]);
SEND_STR(" LG:");
i++;j=0;
while((REC_BUFF[i]!=',')||(j++<1))
SEND_CHR(REC_BUFF[i++]);
SEND_CHR(0x1A);
cmd_lcd(0x01);
cmd_lcd(0x80);
display_lcd("X-: Y-: ");
delay_ms(2000);
}
if(x>180)
{
cmd_lcd(0xC0);
display_lcd("ACCIDENT OCCURED");
mtr=1;
rl=1;
RECEIVE_GPGLL(1000);
cmd_lcd(0x01);
RECEIVE_GPS();
rl=0;
delay_ms(500);
cmd_lcd(0x01);
SEND_STR("AT");
SEND_CHR(0x0D);
delay_ms(500);
SEND_STR("AT+CMGF=1");
SEND_CHR(0x0D);
delay_ms(500);
display_lcd("SENDING SMS...");
SEND_STR("AT+CMGS=");
SEND_CHR('"');
SEND_STR("9948900106");
SEND_CHR('"');
delay_ms(500);
SEND_CHR(0x0D);
delay_ms(500);
SEND_STR("\r\n");
SEND_STR(" MAJOR ACCIDENT OCCURED AT");
SEND_STR("\r\n");
delay_ms(500);
i=1;
while((REC_BUFF[i++]!=',')||(j++<1));
j=0;
SEND_STR("LT:");
while((REC_BUFF[i]!=',')||(j++<1))
SEND_CHR(REC_BUFF[i++]);
SEND_STR(" LG:");
i++;j=0;
while((REC_BUFF[i]!=',')||(j++<1))
SEND_CHR(REC_BUFF[i++]);
SEND_CHR(0x1A);
delay_ms(2000);
cmd_lcd(0x01);
cmd_lcd(0x80);
display_lcd("X-: Y-: ");
}
if(x<140)
{
cmd_lcd(0xC0);
display_lcd("ACCIDENT OCCURED");
mtr=1;
rl=1;
RECEIVE_GPGLL(1000);
cmd_lcd(0x01);
RECEIVE_GPS();
rl=0;
delay_ms(500);
cmd_lcd(0x01);
SEND_STR("AT");
SEND_CHR(0x0D);
delay_ms(500);
SEND_STR("AT+CMGF=1");
SEND_CHR(0x0D);
delay_ms(500);
display_lcd("SENDING SMS...");
SEND_STR("AT+CMGS=");
SEND_CHR('"');
SEND_STR("9948900106");
SEND_CHR('"');
delay_ms(500);
SEND_CHR(0x0D);
delay_ms(500);
SEND_STR("\r\n");
SEND_STR(" MINOR ACCIDENT OCCURED AT");
SEND_STR("\r\n");
delay_ms(500);
i=1;
while((REC_BUFF[i++]!=',')||(j++<1));
j=0;
SEND_STR("LT:");
while((REC_BUFF[i]!=',')||(j++<1))
SEND_CHR(REC_BUFF[i++]);
SEND_STR(" LN:");
i++;j=0;
while((REC_BUFF[i]!=',')||(j++<1))
SEND_CHR(REC_BUFF[i++]);
SEND_CHR(0x1A);
delay_ms(2000);
cmd_lcd(0x01);
cmd_lcd(0x80);
display_lcd("X-: Y-: ");
}
}
}
float adc_convert (void)
{
unsigned char byte0,byte1,byte2;
int i;
float val;
CLK=0;
CS=1;
CS=0;
select_channel();
byte0=byte_write_read(A);
byte1=byte_write_read(C);
byte2=byte_write_read(0x00);
CS=1;
i=(byte1&0x0f);
i=((i<<8)| byte2);
val=((i*5.00)/4096)*100;
return val;
}
//////////////////////////////
float adc_convert1 (void)
{
unsigned char byte3,byte4,byte5;
int i;
float val;
CLK=0;
CS=1;
CS=0;
select_channel1();
byte3=byte_write_read(A);
byte4=byte_write_read(C);
byte5=byte_write_read(0x00);
CS=1;
i=(byte4&0x0f);
i=((i<<8)| byte5);
val=((i*5.00)/4096)*100;
return val;
}
unsigned char byte_write_read (unsigned char a)
{
unsigned char c=0,mask=0x80;
do
{
CLK=1;
if(a&mask)
DIN=1;
else
DIN=0;
CLK=0;
if(DOUT==1)
c|=mask;
mask>>=1;
}
while(mask>0);
return c;
}
////////////////////////////
void select_channel (void)
{
unsigned char x;
x=(channel*2)+0x60;
A = x>>4;
C = x<<4;
}
void select_channel1 (void)
{
unsigned char x;
x=(channel1*4)+0x60;
A = x>>4;
C = x<<4;
}
void init_lcd(void)
{
cmd_lcd(0x28);
cmd_lcd(0x0E);
cmd_lcd(0x06);
cmd_lcd(0x01);
cmd_lcd(0x80);
display_lcd(" WELCOME ");
delay_ms(500);
}
void cmd_lcd(unsigned char c)
{
delay_ms(5);
lcd = ((c&0xf0)|0x02);
lcd = 0;
lcd = ((c<<4)|0x02);
lcd = 0;
delay_ms(20);
}
void lcd_data(unsigned char c)
{
delay_ms(5);
lcd = ((c&0xf0)|0x03);
lcd = 0;
lcd = ((c<<4)|0x03);
lcd = 0;
delay_ms(20);
}
void display_lcd(unsigned char *s)
{
while(*s)
lcd_data(*s++);
}
/////////////////////////////////////////////////////////////////////////////////////
void integer_lcd(int n)
{
unsigned char c[6];
unsigned int i=0;
if(n<0)
{
lcd_data('-');
n=-n;
}
if(n==0)
lcd_data('0');
while(n>0)
{
c[i++]=(n%10)+48;
n/=10;
}
while(i-->=1)
lcd_data(c[i]);
}
/////////////////////////////////////////////////////////////////////
void delay_ms(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<120;j++);
}
void RECEIVE_GPS(void)
{
unsigned int i=0,j=0;
i=1;
while((REC_BUFF[i++]!=',')||(j++<1));
j=0;
cmd_lcd(0X80);
display_lcd("LT:");
while((REC_BUFF[i]!=',')||(j++<1))
lcd_data(REC_BUFF[i++]);
//input=REC_BUFF[i++];
cmd_lcd(0XC0);
display_lcd("LG:");
i++;j=0;
while((REC_BUFF[i]!=',')||(j++<1))
lcd_data(REC_BUFF[i++]);
//nput=REC_BUFF[i++];
}
///////////////////////////////////////////////////////////////////////////////////
void RECEIVE_GPGLL(unsigned long timeout)
{
unsigned int i=0;
char loop = 1;
while(loop)
{
while(RECEIVE_CHR(timeout) != '$');
if(RECEIVE_CHR(timeout) == 'G')
{
if(RECEIVE_CHR(timeout) == 'P')
{
if(RECEIVE_CHR(timeout) == 'R')
{
if(RECEIVE_CHR(timeout) == 'M')
{
if(RECEIVE_CHR(timeout) == 'C')
{
i = 0;
do
{
REC_BUFF[i] =
RECEIVE_CHR(timeout);
if(i > BUFF_LEN-1) break;
}
while((REC_BUFF[i++]!=0x0D)&&(i < (BUFF_LEN-2)));
REC_BUFF[i-1] = 0x00; loop = 0;
}
else loop = 1;
}
else loop = 1;
}
else loop = 1;
}
else loop = 1;
}
else loop = 1;
}
}
////////////////////////////////////////////////////////////////////////////////////
unsigned char RECEIVE_CHR(unsigned long timeout)
{
unsigned char temp=0x00;
while((!RI)&&(--timeout > 0));
if(timeout)
temp = SBUF;
RI = 0;
return temp;
}
void GSM_INIT(void)
{
cmd_lcd(0x80);
display_lcd("GSM INITIALIZING..");
SEND_STR("AT");
delay_ms(1000);
SEND_CHR(0x0D);
}
void SEND_STR(unsigned char *s)
{
while(*s)
SEND_CHR(*s++);
}
void SEND_CHR(unsigned char c)
{
SBUF = c;
//while(TI == 0);
delay_ms(100);
TI = 0;
}
6. Results
Whenever accident or short circuit occurs in the vehicle then the device
sends message to given mobile device.
Message for Major Accident :
After power on the board, we need to wait about 10 secs before to get accurate
accelerometer data from the sensor. After which, the values will begin to stabilize.
when moving and rotating the sensor, and apply forces to it, which causes the
measurements to fluctuate. The net result is that accelerometer data tends to be very noisy,
with brief but significant disturbances. If these can be averaged out, the accelerometer
provides accurate results over timescales longer than the noise disturbances.
Existing system do not work if the system itself damaged in the vehicle accident.
8. Scope of future study
This Project provides the design which has the advantages of low cost, portability, small size.
The platform of the system is AT 89S52 along with accelerometer sensor; GPS and GSM,
interfacing which reduces the alarm time to a large extent and locate the site of accident
accurately. This system can overcome the problems of lack of automated system for accident
location detection. Consequently, the time for searching the location is reduced and the person
can be treated as soon as possible which will save many lives. This system will have broad
application prospects as it integrates the positioning systems and the network of medical based
services.
There is a scope for improvement and as a future implementation we can add a wireless webcam
for capturing the images which will help in providing driver`s assistance.
9. Bibliography
www.8051projects.com
http://www.wikid.eu/