0% found this document useful (0 votes)
121 views17 pages

Project Report

This project develops an accident detection and alerting system using an 8051 microcontroller. The system includes a vibration sensor to detect accidents, a GSM module to send SMS alerts, and an Arduino/GPS module to obtain location data. When an accident is detected, the system sends SMS messages with an "ACCIDENT DETECTED" message to specified phone numbers, makes calls to those numbers, and uses the GPS module connected to an Arduino to get the location of the accident.

Uploaded by

Dhruv Kapadia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views17 pages

Project Report

This project develops an accident detection and alerting system using an 8051 microcontroller. The system includes a vibration sensor to detect accidents, a GSM module to send SMS alerts, and an Arduino/GPS module to obtain location data. When an accident is detected, the system sends SMS messages with an "ACCIDENT DETECTED" message to specified phone numbers, makes calls to those numbers, and uses the GPS module connected to an Arduino to get the location of the accident.

Uploaded by

Dhruv Kapadia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Fall Semester 2019-20

Microcontroller and Its


Applications
(ECE-3003)
Accident Detection and Alerting System using 8051
Microcontroller

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

Components Required and Software 5


Used

Working and Procedure 5

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

Software Used: Keil μVision

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:

1) Connect the LCD data pins to Port P0 of the 8051 microcontroller.


2) Connect RS,R/W,E to the pins P2.0,P2.1,P2.2 respectively.
3) Power the LCD Module with 5V power supply.
4) Connect the Arduino (digital pin 7) to the pin P0.0.
5) Connect GPS Module to the 4th digital pin of Arduino.
6) Power the GPS Module using the Arduino.
7) Connect the vibration sensor to pin P3.2.
8) Power the Vibration sensor with 5V.
9) Connect the RXD of GSM module to P3.1 and TXD of GSM to P3.0.
10) Power the GSM Module with 12V.
11) Power the 8051 microcontroller with 5V supply.
12) Press the reset button.
Code:

MAIN CODE:

#include<reg51.h>
#include"GSM.h"
#include"LCD.h"

#define NUMBER1 "9080515110" //Enter the mobile number


#define NUMBER2 "7016958644"
#define NUMBER3 "9532715168"

sbit vib = P3^2;


sbit arduino = P0^0;

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 comwrt(unsigned char);


void datawrt(unsigned char);
void LCD_initialise();
void display(unsigned char *str);

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;
}
}

void comwrt(unsigned char dat)


7
{
unsigned int i;
LCDDATA=dat;
RS = 0;
RW = 0;
EN = 1;
DELAY;
EN = 0;
}

void datawrt(unsigned char dat)


{
unsigned int i;
LCDDATA=dat;
RS = 1;
RW = 0;
EN = 1;
DELAY;
EN = 0;
}

void display(unsigned char *str)


{
int i;
for(;*str!=0;str++) {
datawrt(*str);
DELAY;
}
}

GSM:

code unsigned char SMS1[2] = "AT" ;


code unsigned char SMS2[9] = "AT+CMGF=1" ;
code unsigned char SMS3[8]= "AT+CMGS=" ; // send "
code unsigned char SMS4[3]= "ATD" ; // send "
code unsigned char SMS5[3]= "ATH" ; // send "

void sendSMS(unsigned char *num , unsigned char *msg);


void delay1(unsigned int tim);
void sendserial(unsigned char mydata1);
void call(unsigned char *num1);

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);

void call(unsigned char *num1)


{
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<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 delay1(unsigned int tim)


{
unsigned int h;
for(h=0;h<=tim;h++) {
TMOD=0X21;
TH0=0x4B;
TL0=0xFD;
TR0=1;
while(TF0==0);
TF0=0;
}
}

void sendserial(unsigned char mydata1)


{
TI=0;
SBUF= mydata1;
while(TI==0);
}

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

volatile float minutes, seconds;


volatile int degree, secs, mins;

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");
}
}

static void smartDelay(unsigned long ms)


{
unsigned long start = millis();
do
{
while (GPS_SoftSerial.available()) /* Encode data read from GPS while data is available on
serial port */
12
gps.encode(GPS_SoftSerial.read());
/* Encode basically is used to parse the string received by the GPS and to store it in a buffer
so that information can be extracted from it */
} while (millis() - start < ms);
}

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:

1) When the accident is not detected, that is no vibration is sent:

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

You might also like