Project Report
Project Report
Done by-
Sourav(17BEC0710)
Romanch Sachdeva(17BEC0762)
Pavithra(17BEC0534)
Professor: Karthikeyan B.
1
Contents
Topic Page
Abstract, Aim 3
Block Diagram 3
Circuit Diagram 4
Code 6
Simulation Photo 13
Result Snapshot 14
Msg Photo 15
Future Scope 17
2
Abstract:
This project is Accident Detection and Alerting System using 8051 Microcontroller. When an
individual riding his/her bike, meets with an accident, there is a chance that the individual
may suffer from a serious injury or expire instantaneously and there is no one around to help
him. Well this system is a solution to the problem. The system acts as an accident
identification system that gathers and sends this vehicle information that met with an
accident, and conveys it to the nearest control room. For this the user vehicle is fixed with a
GSM module and vibration sensor along with microcontroller. Whenever a user vehicle meets
with any accident, the vibration sensor detects and gives its output. This output is then
detected by the microcontroller. Now the microcontroller sends this change detection signal
to a GSM Module. GSM Module begins sending the accident data by SMS. We can give anyone
number. for example police number, ambulance number, doctor number etc. Here we are
also using LCD Module. This displays the status.
Aim:
To make a Accident Detection and Alerting System using 8051 Microcontroller which will help to
reduce the number of accidents happening in the surrounding.
Block Diagram:
3
Circuit Diagram:
4
Components Required:
• 8051 Development board
• LCD Module
• GSM Module
• Vibration Sensor
• 8051 Microcontroller
• Arduino Uno
• GPS Module
Working:
1) When the circuit is switched on “INITIALISING” is displayed on the LCD Module for
some time.
2) The Vibration Sensor attached to the 8051 Microcontroller on pin P3.2 continuously
checks for the vibrations.
3) If there is no accident detected (no signal is sent to the microcontroller) and a message
of “ACCIDENT DETECTED: NO” is displayed on the LCD Module.
4) If an accident is detected, vibration sensor sends a signal to the microcontroller and a
message of “ACCIDENT DETECTED: YES” is displayed on the LCD Module.
5) Microcontroller also sends a signal to the GSM Module (connected to pin P3.0 and
P3.1), when the accident is detected.
6) The GSM Module sends a message “ACCIDENT DETECTED” to the numbers specified
in the code.
7) The GSM Module also gives a call to the numbers specified.
8) The Microcontroller also sends a high logic to the Arduino (connected to the pin P0.0)
when an accident is detected.
9) When a high logic is detected on the Arduino, the signal is given to the GPS Module.
10) The GPS location (longitude, latitude, altitude and time) is displayed on the serial
monitor.
Procedure:
MAIN CODE:
#include<reg51.h>
#include"GSM.h"
#include"LCD.h"
void main()
{
unsigned int r;
init_serial();
LCD_initialise();
comwrt(0x80);
display("INITIALISING ... ");
for(r=0;r<60000;r++);
comwrt(0x80);
display("GSM ACCIDENT DET");
comwrt(0xC0);
display(" VIBRATION: NO ");
arduino=0;
while(1) {
if(vib==1) {
arduino=1;
comwrt(0x80);
display("VIBRATION DETECT");
comwrt(0xC0);
display(" VIBRATION: YES ");
for(r=0;r<30000;r++);
for(r=0;r<30000;r++);
comwrt(0x80);
display("SENDING MSG .... ");
sendSMS(NUMBER1,"ACCIDENT DETECTED");
sendSMS(NUMBER2,"ACCIDENT DETECTED");
sendSMS(NUMBER3,"ACCIDENT DETECTED");
comwrt(0xC0);
display(" MSG SENT ");
for(r=0;r<30000;r++);
for(r=0;r<30000;r++);
6
for(r=0;r<30000;r++);
comwrt(0x80);
display("CALLING .........");
call(NUMBER1);
call(NUMBER2);
call(NUMBER3);
comwrt(0x80);
display("GSM ACCIDENT DET");
}
else
{
arduino=0;
comwrt(0xC0);
display(" VIBRATION: NO ");
}
}
}
LCD:
#define LCDDATA P1
#define DELAY for(i=0;i<1200;i++)
sbit RS = P2^0;
sbit RW = P2^1;
sbit EN = P2^2;
void LCD_initialise()
{
unsigned int i,j;
int com[5]={0x38,0x0C,0x01,0x06,0x80};
for(j=0;j<=4;j++) {
comwrt(com[j]);
DELAY;
}
}
GSM:
unsigned char i;
8
void sendSMS(unsigned char *num , unsigned char *msg)
{
for (i=0;i<2;i++)
sendserial(SMS1[i]);
sendserial(0X0D);
delay1(60);
for (i=0;i<9;i++)
sendserial(SMS2[i]);
sendserial(0X0D);
delay1(60);
for (i=0;i<8;i++)
sendserial(SMS3[i]);
sendserial(0x22); // "
for(;*num!=0;num++)
sendserial(*num);
sendserial(0x22); // "
sendserial(0X0D);
delay1(60);
for(;*msg!=0;msg++)
sendserial(*msg);
sendserial(0X1A);
delay1(80);
for (i=0;i<9;i++)
sendserial(SMS2[i]);
sendserial(0X0D);
delay1(60);
for (i=0;i<3;i++)
sendserial(SMS4[i]);
for(;*num1!=0;num1++)
sendserial(*num1);
9
sendserial(0x3b);
sendserial(0X0D);
delay1(80);
delay1(600);
for (i=0;i<3;i++)
sendserial(SMS5[i]);
delay1(80);
}
void init_serial()
{
SCON=0x50;
TMOD=0x21;
TH1=0xFD;
TL1=0xFD;
TR1=1;
}
GPS:
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
/* Create object named bt of the class SoftwareSerial */
SoftwareSerial GPS_SoftSerial(4, 3);/* (Rx, Tx) */
10
/* Create an object named gps of the class TinyGPSPlus */
TinyGPSPlus gps;
#define gps_inp 7
void setup() {
Serial.begin(9600); /* Define baud rate for serial communication */
GPS_SoftSerial.begin(9600); /* Define baud rate for software serial communication */
pinMode(gps_inp,INPUT);
}
void loop() {
if (gps_inp==1){
smartDelay(1000); /* Generate precise delay of 1ms */
unsigned long start;
double lat_val, lng_val, alt_m_val;
uint8_t hr_val, min_val, sec_val;
bool loc_valid, alt_valid, time_valid;
lat_val = gps.location.lat(); /* Get latitude data */
loc_valid = gps.location.isValid(); /* Check if valid location data is available */
lng_val = gps.location.lng(); /* Get longtitude data */
alt_m_val = gps.altitude.meters(); /* Get altitude data in meters */
alt_valid = gps.altitude.isValid(); /* Check if valid altitude data is available */
hr_val = gps.time.hour(); /* Get hour */
min_val = gps.time.minute(); /* Get minutes */
sec_val = gps.time.second(); /* Get seconds */
time_valid = gps.time.isValid(); /* Check if valid time data is available */
if (!loc_valid)
{
Serial.print("Latitude : ");
Serial.println("*****");
Serial.print("Longitude : ");
Serial.println("*****");
}
else
{
DegMinSec(lat_val);
Serial.print("Latitude in Decimal Degrees : ");
Serial.println(lat_val, 6);
Serial.print("Latitude in Degrees Minutes Seconds : ");
Serial.print(degree);
Serial.print("\t");
Serial.print(mins);
Serial.print("\t");
11
Serial.println(secs);
DegMinSec(lng_val); /* Convert the decimal degree value into degrees minutes seconds
form */
Serial.print("Longitude in Decimal Degrees : ");
Serial.println(lng_val, 6);
Serial.print("Longitude in Degrees Minutes Seconds : ");
Serial.print(degree);
Serial.print("\t");
Serial.print(mins);
Serial.print("\t");
Serial.println(secs);
}
if (!alt_valid)
{
Serial.print("Altitude : ");
Serial.println("*****");
}
else
{
Serial.print("Altitude : ");
Serial.println(alt_m_val, 6);
}
if (!time_valid)
{
Serial.print("Time : ");
Serial.println("*****");
}
else
{
char time_string[32];
sprintf(time_string, "Time : %02d/%02d/%02d \n", hr_val, min_val, sec_val);
Serial.print(time_string);
}
}
else{
Serial.print("NO ACCIDENT DETECTED");
}
}
void DegMinSec( double tot_val) /* Convert data in decimal degrees into degrees minutes
seconds form */
{
degree = (int)tot_val;
minutes = tot_val - degree;
seconds = 60 * minutes;
minutes = (int)seconds;
mins = (int)minutes;
seconds = seconds - minutes;
seconds = 60 * seconds;
secs = (int)seconds;
}
Simulation Photo:
13
Result:
2) When the accident detected, that is vibration is sent and message is sent using gsm
module:
14
15
16
Advantages:
• Quick response is achieved
• Easy to maintain and repair
• Simple in construction
• Continuous operation is possible without stopping
• Immediate help can be sent to the location where accident has occurred
Disadvantages:
• If the accident occurs in a region where network connection is poor there is a
chance that the gsm module might not be able send sms .
• In case of a huge accident there is a chance that the equipment might get
damaged.
Future Scope:
This system can be upgraded to prevent accident caused due to drink and drive. We
can also add an alcohol detector which will sense if the driver is drunk and would not
start the vehicle.
17