Sei sulla pagina 1di 63

1

“CAR DRIVER SAFETY DEVICE”

Aisha Imran 15k-2472


Abdullah Iftikhar 15k-2393
Syed Saad Azim 15k-2450

INTERNAL ADVISOR
ENGR AQIB NOOR

INTERNAL CO-ADVISOR
ENGR.UMAIR NAEEM

EXTERNAL ADVISOR
DR. MUHAMMAD SHAHID SHEIKH

DEPARTMENT OF ELECTRICAL ENGINEERING


NATIONAL UNIVERSITY OF COMPUTER AND EMERGING SCIENCES -FAST
2

DECLARATION

We hereby declare that this project report entitled “CAR DRIVER SAFETY
DEVICE” submitted to the “DEPARTMENT OF ELECTRICAL
ENGINEERING” is a record of an original work done by us under the guidance of
Supervisor “SIR AQIB NOOR” and Co-supervisor “SIR UMAIR NAEEM” that no
part has been plagiarized without citations. Also, this project work is submitted in the
partial fulfillment as per required for degree of Bachelor of Electrical Engineering.

Members Signature

Syed Saad Azim

Muhammad Abdullah
Iftikhar

Ayesha Imran

Supervisor: Signature

Engr. Aqib Noor

Date:

Place:
3

ACKNOWLEDGEMENTS

By the grace of Allah Subhanahu Wa Ta'ala, we were able to finish our project

smoothly within due time. We would like to thank our parents for their constant

support, our teachers for providing guidance and sharing us their wisdom and

lastly our FYP mates for helping us during the course of this project.

We express our deepest appreciation for our internal advisor Sir Aqib Noor and

co advisor Sir Umair Naeem. We were very fortunate to have them as an

advisor. They guided us whenever we came across a few problems and helped us

in overcoming the obstacles we faced during our project. We have nothing but

pure respect and admiration for our teachers and we will never forget the

kindness they had shown towards us.


4

TABLE OF CONTENTS

Chap Topic
Page
1 Introduction
1.1 Introduction
1.2 Motivation
1.3 Literature Review
1.4 Problem Defintion &
Solution
2 Methadology
2.1 Basic Tools
2.2 Main Project Features
2.3 Frame & Body Design
2.4 Complete Circuit Diagram
3 Code & Simulation Results
3.1 Programming Code-1
3.2 Programming Code-2
3.3 Simulation Results
4 Cost,Future Work &
Conclusion
4.1 Cost Analyses
4.2 Future Work
4.3 Conclusion
References
5

TABLE OF FIGURES

Chap Figure Page


2 Chapter-2

2.1

2.2

2.3

2.4

2.5

2.6

2.7

2.8

2.9

2.10

2.11

2.12

2.13

2.14

2.15

2.16
6

2.17

2.18

2.19

2.20

2.21

2.22

2.23

2.24

2.25

2.26

2.27

2.28

3 Chapter-3

3.1 (a,b)

3.2(a,b)

3.3 (a,b)

3.4(a,b)

3.5(a,b)
7

ABSTRACT

Car and law developers are cooperating together for many years to make improvements on cars

so that people can have safe journeys. According to WHO (World Health Organization), around

1.25 million people die each year due to car accidents. This project consists of many safety

devices which will provide safety to drivers in case of many emergencies situations.

Furthermore, this system ‘Car driver Safety Device’ is designed specifically to minimize car

accidents as much as possible. It consists of alcohol sensor which detects alcohol in the driver’s

body, eye blink sensor which detects drowsiness of the driver, PIR (motion sensor), it detects the

presence of an un authorized person in the car in case of driver’s absence, ultra sonic sensors

gives anti-collision detection warning, fire sensor detects if a fire occurs inside the car, 800L

module is used for tracking the car’s location through GPS and informs to a predefined number

in case of any accident. In short, this system will provide maximum solutions for the safety of

vehicle, drivers as well as passengers.


8

CHAPTER-1
INTRODUCTION

1.1 Introduction
Due to increasing number of cars the demand of safety and security of the
drivers are also increasing day by day which signifies the importance of this project in this
modern world. These days, majority of road accidents are caused by drink-driving. Drunken
drivers are in an unstable condition and so, rash decisions are made on the highway which
endangers the lives of road users, the driver inclusive. Furthermore, it was found that vehicle
safety has become a high priority during the process of purchasing of new vehicles. Previous
researches on car safety includes a new kind of air bag system, anti-lock braking system,
password protected vehicle monitoring system, advanced auto mobile safety features, and
smart vehicle protection system. The microcontroller board used is Arduino Mega which is able
to read inputs through sensors and give an output i.e activating a motor or an LED. This
research is a system of combination of vehicle safety features of the driver and anti-theft
monitoring and controlling system with the help of tracking. Furthermore, this device includes
fire sensor, ultrasonic sensor, motion sensor, eye sensor, alcohol sensor, GSM module 800L
and GPS. The GSM module acts as an interface for communication between the driver and a
predefined number to send alert messages in case if an emergency occurs. The overall
approach of this project is to improve the safety and security of the car through advanced
technology by using social communication media

1.2 Motivation
Remember the days when safety features on a car included anti-lock brakes, airbags, seatbelts
and traction control? Those days are over. Today most buyers will not let go of their hard-earned cash
unless the majority of the latest safety features and system are build in their new car. This project is made
specifically for this purpose it includes majority of the safety features needed to drive safely.For the last
30 years, or even further back, most of the focus on making vehicles safer was on protection That's why
seatbelts and airbags were invented but all of these features are for the purpose of reducing the risk of
being injured, given that crashes are going to occur which can only be reduced with computer
technology and sensing technology. The microcontroller board used is Arduino Mega which is able to
read inputs through sensors and give an output i.e activating a motor or an LED.The interfacing between
9

the hardware and software is done using parallel port of the personal computer. This system contains a
fire protection, alcohol detection, collision prevention , drowsiness detection, accident spot identification
and also anti-theft tracking features. All of these features are controlled by sensors which send a signal to
Arduino. GSM and GPS modules are connected to the Arduino that sends a message to the predefined
mobile and informs about the occurrence of an accident. In total the system is aimed to provide a total
protection to the vehicle.

1.3 Literature Review


According to the world health organization 80% of cars which are sold are not
accommodating with main safety features. Even though construction of new and improved roads
have minimized accidents, injuries and deaths. Nevertheless auto collisions are still mostly the
leading cause of death. The implementation and interfacing of the car safety mechanism is referred
from many of the few citations, with the help of these citations this prototype was developed which
contains following features.
An Ultrasonic sensor is the first safety feature is anti-collision mechanism which helps the driver to
prevent the collision of rear and front end of the car, should the other vehicle suddenly stops or
speeds up . One of the most significant role of the driver is to adjust his reaction time which depends
on the safe distance needed to prevent any major or minor collisions which brings back to the role of
the ultrasonic sensor mentioned before .The ultrasonic sensor helps in detection of any obstacle,
object or person within 500 meters. it also contains a transmitter which gives out an ultrasonic wave
to recognize any object, the transmitter consists of piezo electric crystal which resonates up to a
certain frequency which in turn converts electrical energy to acoustic energy.
The second safety feature is alcohol detection mechanism. This system will examine the driver’s
breath for concentration of carbon dioxide and ethanol gas molecules. These molecules will resonate
infrared beam which has a certain wavelength which is then measured by the
sensor acting as a tracking device, if the reading exceeds a certain threshold, an automatic lock will
activate and the car will not start.
The third feature is drowsiness detection system. This feature detects whether the driver is sleepy or
not using infrared in order to minimize the road accidents that occur on highways. An Eye blink
sensor monitors the variations in time for the eye to blink if the eye is closed or the time variation in
eye blink exceeds a certain threshold then the output is high as a result an alarm will sound.
The fourth feature is fire detection alarm system. This feature allows the detection of fire and alerts
the driver through a buzzer sound. The flame sensor contains a photodiode which detects light as
10

well as an op amp which adjusts the sensitivity through a potentiometer. If a fire is detected, an
alarm is sounded and a relay switch connected to the motors of the car window is switched on which
in turn rolls down the windows of the car.
The fifth feature is vehicle tracking system. This feature requires two sensors shock sensor and
accelerometer which is used to send the location of the vehicle through GPS and GSM module
800L.When there is an accident the shock sensor is used to send the data to the GSM module. The
GSM module has a SIM implanted which automatically sends a distress signal to the predefined
number and notify the condition of the vehicle as well the the location of the vehicle where the
accident took place through GPS. The accelerometer is used to monitor the acceleration and the axis
of the vehicle, if there is a sudden de-acceleration of vehicle as well as sudden change in the axis of
the vehicle it compares the value with the threshold value and if the value is greater than the
threshold value the GSM module sends a message to the predefined number to notify about the
occurrence of the accident of the vehicle.

1.4 Problem Definition & Solution


We all know that the car accidents are happening all across the world as a result of careless
and rash driving as well as increase in traffic. Many accidents occur due to alcohol consumption.
The purpose of this project is to develop a series of system to provide safety to the driver of a vehicle
and to prevent the occurrence of accidents through sensor interfacing. By analyzing the reasons and
reports of the occurrence of increase in accidents we came up with a number of safety features for
the driver.
To prevent drunken drivers which create havoc in the society, we have constructed an alcohol
detection system which will prevent the drivers to drive with alcohol consumed. The alcohol sensor
detects the alcohol by breathing in the sensor which will activate ignition relay to shut off engine.
In case of fire, the fire sensor will activate an alarm system and the windows of the car will
automatically roll down to prevent causalities. In case of accident, vehicle detection system is
created to inform the incident to a third party will arrive as quickly as possible. This system analyses
the car condition and send a distress signal to a predefined number accordingly as well as the
location of the car through GPS.
In addition to these features there is also an anti-sleep system and anti-collision system included
which will further enhance the protection of the driver. The anti-sleep system helps the driver to stay
awake while driving. The anti-collision system will alert the driver if a speeding vehicle is coming
towards the car it also helps the car to park safely.
11

CHAPTER 2
METHADOLOGY
This project is basically a combined network of various sensors in which a micro-controller acts as
a main interfacing host. The response from the interfaced sensors either analog or digital is notified
to microcontroller via different pins and then micro-processor generates the output as per burned
code requirement..There are multiple tools that are used in this project which will be discussed in
this next section.

2.1 BASIC TOOLS

 Arduino Mega 2560 R3


The ARDUINO MEGA 2560 microcontroller is designed to work on
complex projects. It provides a large room to expand our task space with 54 digital
I/0 pins, 16 analog input pins, 4 UART ports, crystal oscillator of 16 MHz, USB jack, a
power jack, ICSP header and reset button. It can be powered via AC to DC Adapter and
also contains a usb to pc port in order to connect with a pc.
PIN CONFIGURATION & SPECIFICATIO

FIG 2.1
12

GND Pin: The board has 5-GND pins

Reset (RST) Pin: The RST pin can be used for initializing the board by setting it to low.

VIN Pin: Range of input voltage ranges from 7volts to 20volts.The board has a voltage regulator

which bucks the voltage to 5volts.

Serial Communication: These pins like TXD and RXD transmit & receive the serial data. Tx

indicates data transmission whereas RX indicates data receiving. The serial pins have four

combinations. For serial 0, it is Tx (1) and Rx (0), for serial 1 it is Tx(18) & Rx(19), for serial 2 it is

Tx(16) & Rx(17), and at last for serial 3, it is Tx(14) & Rx(15).

External Interrupts: The external interrupts are found by using 6-pins like interrupt 0(0), interrupt

1(3), interrupt 2(21), interrupt 3(20), interrupt 4(19), interrupt 5(18). These pins generate interrupts

through different ways like giving LOW value, rising or falling edge or changing value of the

interrupt pins.

AREF: AREF stands for Analog Reference Voltage that is a reference voltage for analog inputs.

Analog Pins: There are 16-analog pins embedded on the board marked as A0-A15. The analog pins

on this board can be utilized as digital I/O pins.

I2C: The I2C communication is controlled by two pins 20 & 21 where 20-pin is Serial Data Line

(SDA) used for holding the data & 21-pin is Serial Clock Line (SCL) utilized for data synchronization

among the devices.

SPI Communication: SPI stands for serial peripheral interface that is used to transmit data among

the controller & other parts. It includes four pins i.e. MISO (50), MOSI (51), SCK (52), and SS (53)

are utilized for communication of SPI.


13

 Arduino Nano
The miniature version of ardiuino having 16 I/O pins (6 are PWM pins) and 8
Analog pins. It provides a much small room and used to perform simpler tasks.

FIG 1.2

 Infrared Sensor Module


This sensor emits infrared radiations in order to sense the objects in surrounding. It
gives a digital “HIGH” at ideal condition. When an object is placed within its range, the
radiation is reflected or bounces back setting the response to digital “LOW”. It has 4 pins
Vin, Gnd, D0 and A0.

Pin1 (VCC pin): Voltage from 3.3V-5.3V


Pin2 (GND): ground pin
Pin3 (AOUT): analog output pin
Pin4 (DOUT): digital output pin

FIG 2.3
14

 MQ3 Gas Detector Module


This sensor detects the presence of gasses like LPG, Alcohol, Propane, Hydrogen,
CO and even methane in the surrounding. It is triggered and responds with a digital “HIGH”
output when any of the gases are present within its range. It contains 4 pins Vcc (5v), GND,
A0 (Analog) & D0 (Digital).

FIG 2.4
 9 V Battery
The battery is to power the Arduino Module in order to carry freely.

FIG 2.5

 Buzzer
The buzzer consists of two pins +ve & -ve attached to it with a ceramic disc inside
it. On passing electric current, the disc vibrates and produces a shrill sound. It is
normallyused for alarming or “HIGH” indications. It contains two pins Vcc(5volt) & GND
15

(ground).

FIG 2.6
 Relay Module
A 5V relay module is a device that is normally used for switching. In this project it
is used for ignition switching upon activation of alcohol sensor. It contains 6 pins
Vcc(5v),Gnd(Ground) & In 1- 4 (digital input).

FIG 2.7
 LED
Micro LED light indicators up to 5mm in size.

FIG 2.8
16

 Ultrasonic Sensor HC-SR04


This sensor measures the distance of an object by emitting sound waves at a high
frequency almost in audible to human. The distance is measured when a sound wave is
passed at a specific frequency and reflects back from the object within its range.
It consist of 4 pins,Vcc (5v),Trig (trigger pin),Echo (echo pin) & GND (ground pin). The
trigger pin pulses ultrasonic waves through transmitter whereas the echo pin records the
time taken by the wave to return at receiver

FIG 2.9
 5v DC Motor: -
DC motor with two terminals +ve & -ve works on the principle of electromagnetic
induction. It is used in this project for sliding down car window.

FIG 2.10

 OLED
OLED or organic light emitting diode is a unique kind of display module that
contains thin organic layers rather than crystalline layers in other LEDs. They are more
energy efficient, provide much wider view and dark displays (best for dark
environments).They work on I2C protocol (two wire communication).It contains 4 pins
Vcc(5v),Gnd(Ground),SCL(serial clock pin) & SDA (serial data transfer pin).
17

FIG 2.11

 KY031 Shock Sensor


This shock sensor module senses the shockwave from the surrounding possibly if,
anything is rammed or broken resulting in sensor activation. It contains an oscillator which
vibrates when a shock wave is produced and a digital “HIGH” output is obtained at the
output pin. It contains three pins Vcc, GND and D0.

FIG 2.12

2.2 Main Project Features & Working:-

 Anti-Sleep System:-

This feature consist of a light weight plastic goggle with a circuitry of IR sensor
18

Attached to it.IR sensor of a minimal range monitors the blinking of an eye which generates
Digital “HIGH” signal if the eye lid is closed for more than 3 seconds. A buzzer is triggered to
alarm or awake the subject.

Working: -
We know that IR sensor emits Infrared Rays at some predefined range. Some IR
sensors also contain potentiometer to control range. At ideal condition, IR sensor generates
digital “HIGH” Output due absence of any obstacle within its range. Soon as some object or
obstacle is placed, the IR rays will bounce back setting the module response to digital
“LOW”. The low “Output” response will trigger the buzzer to honk.

FIG 2.13

Circuit Diagram
19

FIG 2.14

Flow Chart

Start

Check for
obstacles

YES NO

Turn On buzzer If any=0? Check again


Output=1

 Alcohol Detection System: -


In this feature, a relay module is attached with an alcohol sensor which is triggered upon the
20

sensor activation and shuts the car ignition to “OFF” position. This is how the subject
cannot drive with alcohol consumed.

Working: -
The MQ3 Gas sensor module has the ability to detect the presence of gases like propane,
methane, alcohol etc.It contains a layer of tin oxide whose electrical conductivity increases with the
presence of alcohol in air. It gives both digital and analog output.

Circuit Diagram: -

FIG 2.15

Flow Chart
21

 Anti-collision System: -
An anti-collision system consists of an ultrasonic sensor which helps the driver to navigate through
traffic as well as alerts the driver from possibilities of collision occurrence. Furthermore, it also helps the
22

driver to stay at a safe distance from the other vehicles. This system also solves the problem of accidents
occurring due to poor visibility. The driver can be warned about the obstacle either through an alarm or a
voice message by calculating the distance between the obstacle and the car. This system aim is to further
improve the overall control system and to increase the robustness of the car in case of the detection of any
kind of obstacle, thus increasing the safety and minimizing the risk in the aspect of vehicle technology.

Working: -
Sensors, microcontroller and alert signals are the key factor for collision avoidance, monitoring and
control which is implanted in the system. As shown below the front and the back of the car consists of
ultrasonic sensors which detect obstacles and pass the information to the microcontroller. As from the
sensor name, it clearly indicates that it emits ultrasonic waves. The sensor as discussed earlier triggers the
ultrasonic waves through transmitter when a pulse is applied at TRIG pin. Soon as we place some obstacle
within the wave’s path, it will reflect back and collected at receiver. The echo pin pulses to HIGH as the
wave transmits and turns LOW on its return. The width of the pulse is the time taken by the wave to return.
This sensor will not wait for more than 38mS (milliseconds) as this is the maximum time range. It indicates
no obstruction within the wave path setting the echo pulse automatically to LOW. The time is recorded and
the distance is calculated by speed distance
formula,

Distance-SpeedxTime, where Speed of sound is 340m/s


23

FIG 2.16

FIG 2.17
24

Description and Circuit Diagram

FIG 2.18

The ultrasonic sensor has four pins: the VCC pin is connected to the 3.3v pin of the Arduino. The
ground pin is connected to the ground pin of Arduino. The trigger pin is connected to pin 7 of the Arduino.
The echo pin is connected to pin6 of Arduino. The two LEDs are connected to pin 22 and 24 and the
buzzer is connected to pin 30. The negative leg of buzzer and leds are connected to ground. The red led
lights up when the distance between the car and the object is less than 20 while the blue led lights up when
the distance is between 20 and 50.
25

FlowChart:-
26

 Fire Detection System: -

It is said that 80% of the losses due to occurrence of fire would have been

prevented if the fire was detected immediately. In This system a flame sensor is interfaced with

the arduino to detect fire inside the car. The purpose of this system is to detect fire before it goes

out of control. The flame sensor continuously monitors the car and alerts the driver in case of fire

by activating a buzzer and led light. As a result the windows are pulled down so that the driver

and the passenger can leave the car in case the door is stuck. The reason we used a flame detector

for this system is because it can give us the fastest response in case of fast developing flaming

fires. The circuit can be installed with the car engine.

Working: -
The fire emits a small amount of Infra-red light, which is received by the Photodiode (IR
receiver) mounted on a flame sensor module. The Op-Amp is used to check for change in voltage across the
IR Receiver, hence if fire is detected the output pin (DO) sets to 0V (LOW) and 5V (HIGH) at ideal
condition. Soon as we receive a LOW output, a buzzer will beep with and a dc motor is turned ON which
slides down the glass window.

Circuit Diagram:- FIG 2.19


27

Flow Chart:-

 Vehicle Tracking System: -


This is the most unique and important feature of this module. What happens
eventually in a car accident is, either the subject dies on the spot or gets unconscious due to injuries.
How the subject shall notify for the rescue? To overcome this problem, we have devised a system by
using GPS (Global Positioning System) and GSM (Global System for Mobile) that will track the
accident location and a text message is sent to notify the other person via GSM module. Text message
will contain the location plus a warning message. Let’s discuss the working in detail.
The system comprises of 4 elements
(1) GSM Module 800L
(2) KY031 Shock Sensor
(3) MPU6050 Module
(4) GPS Module
28

1. GSM Module 800L: -


GSM or Global System Mobile is a system that provides a medium for data
exchange and communication facilities between two or more networks. This module plays
an important role in the field of wireless communication and acts as a key component in
mobile phones. It operates on TDMA (Time Division Multiple Access) technique to transfer
information which divides a single channel into multiple time slots. The module contains a
spiral antenna (network connection), UFL connector, Status bar, GSM 800 Chip, SIM jack
and 12 pins for microcontroller interfacing. The modules operating voltage ranges from
3.7-4.2 Volts which can be supplied via Li-Po batteries or DC-DC Buck Converter.

FIG 2.20

B
29

FIG 2.21

Module Features: -
GSM 800L Module provides the following features:

 Quad Band ,to avail connectivity anywhere worldwide


 Connectivity to any 2G network via SIM
 Can make and receive calls via speaker and mic
 Can send and receive text messages
 Can connect to FM radio signals etc

2.KY031 Shock Sensor: -


This module is good for adding shock and knocks detection to your project.
It will find an occurrence supported percussion (like the knock-knock typical of
knocking) to activate operate, to command a relay etc.The detector incorporates a Very
light spring blocked at one finish. the other finish is suspended on top of an
outsized contact plate. once an occurrence happens like a stroke, the spring moves at
intervals its clear protection by striking the plate. This event closes the
circuit permitting the passage of current. this may be taken from microcontroller as a
trigger event or HIGH output.
30

Specifications: -

> Supply voltage: 5VDC


> PCB dimensions: 10 x 13 mm

> Overall dimensions: 30 x18 x 15 mm

> Number of terminals: 3


> Code: KY031
> Type: Knock Sensor

FIG 2.22

3. MPU6050 Module: -
MPU6050 sensor module is a complete 6-pivot Motion Tracking Device. It joins 3-pivot
Gyroscope, 3-hub Accelerometer and Digital Motion Processor all in a small module. It uses I2C
bus to communicate with microcontrollers. It has an auxiliary I2C bus to speak with other sensor
gadgets like 3-hub Magnetometer, Pressure sensor and so on. The 3-pivot Magnetometer provides
31

a complete 9-axis motion output if connects with I2C bus. Lets discuss the working elements of
this module.

3-Axis Gyroscope:-
This module comprises of 3-axis Gyroscope having Micro Electro Mechanical System
(MEMS) technology. It measures angular velocity on the X, Y, Z axes as shown in figure.

FIG 2.23

Due to rotation of gyro about any of axes (X, Y, Z), a Coriolis Effect produces vibration which is
detected by MEM inside MPU6050.The generated signal is amplified, demodulated, and filtered to
produce a voltage proportional to the angular rate.
This voltage signal is converted to digital using 16-bit ADC (Analog to Digital Converter) to sample
each axis. The complete-scale range of output is +/- 250, +/- 500, +/- 1000, +/- 2000. It measures
angular velocity along all axes in degrees per second.
32

3-Axis Accelerometer:-
This module comprises of 3-axis Accelerometer with Micro Electro Mechanical (MEMs)
technology. It detects tilting angle or inclination along the X, Y and Z axes as shown in below figure.

FIG 2.24

Acceleration along the axes diverts the moving object. This displacement of moving object
unbalances the differential capacitor which results in sensor output. The output amplitude is
proportional to acceleration whereas a 16-bit ADC is used to get digital output. The complete-scale
ranges of acceleration are +/- 2g, +/- 4g, +/- 8g, +/- 16g measured in meters per second square. The
sensor measures 0g on X and Y axis and +1g on Z axis when placed on a flat surface
33

DMP (Digital Motion Processor):-


The on chip Digital Motion Processor (DMP) computes motion processing algorithms. It
collects data from gyroscope, accelerometer and from another sensor such as magnetometer and
processes the data. It gives motion data like roll, pitch, yaw angles, landscape etc. It reduces the
processing of host in computing motion data. The resulting data can be read from DMP registers.

FIG 2.25
The MPU-6050 module has 8 pins,

INT: Interrupt digital output pin.

AD0: Analog to Digital pin (converts the analog signal to digital)

XCL: Auxiliary Serial Clock pin. This pin connects other I2C interface enabled sensors SCL pin to
MPU-6050.

XDA: Auxiliary Serial Data pin. This pin is connects other I2C interface enabled sensors SDA pin to
MPU-6050.

SCL: Serial Clock pin. Connect this pin to microcontrollers SCL pin.

SDA: Serial Data pin. Connect this pin to microcontrollers SDA pin.

GND: Ground pin. VCC: Power supply pin. Connect this pin to +5V DC supply.
34

4. GYNEO6MV2 GPS Module: -


GPS or Global Position System is a navigation network consists of about 30
satellites revolving the earth. These satellites transmit information to the GPS receiver which calculates
how far each satellite is. In order to point out location on the planet, a technique known as Trilateration
is used. Suppose there are three satellites orbiting above you. If you know how far you are from the
three satellites, you can easily pin point your location.
Here we are interfacing GYNEOMV2 GPS module with Arduino It has the following
specifications.
Specifications: -
>Module antenna, strong signal and mini size.
>EEPROM for saving configuration parameter data when power down.
>Compatible with different flight control modules.
>Power supply: 3V-5V
>The standard baud rate: 9600
>Module size: Approx. 25 mm x 35 mm / 0.98″ x 1.37″
>Supply Voltage: 2.7 to 3.6V
>Supply current: 67 mA
>Antenna gain: 50 dB
>Operating temperature:-40 to 85°C
>Antenna Type: Passive and active antenna
>Interfaces: UART, USB, SPI.
Pin Description:
>Vcc-Supply Voltage >Gnd-Ground pin
>TX and RX- acts as UART interface for communication.
> PPS (Pulse per Second) pin used to time things accurately.

FIG 2.26
35

Working: -
During accident, the collision generates a shock wave which activates the shock sensor. The
GPS records the location of accident and sends the information to the GSM module which further directs
an emergency message (with location) to the predefined number. In case of car tilt monitored by the
accelerometer, an emergency message “The car has being tilted” is sent.

Circuit Diagram: - FIG 2.27


36

2.3 FRAME & BODY DESIGN


We have designed a wooden frame to create a driving seat model with dimensions up to 6ft
x 4ft. An ideal model based on AUTOCAD tool is attached below.

FIG 2.28
2.4 COMPLETE CIRCUIT DIAGRAM OF THE MODULE:-

FIG 2.29
37

CHAPTER-3
PROGRAMMING CODE & SIMULATION RESULTS

3.1 Programming Code-1

The following code is for OLED, collision sensor, eye blink sensor, MQ3 sensor, relay,
motor and fire sensor. We have applied conditional structure (if-else) technique for each sensor in
our code. This technique forces the sensor to act or stay idle as per state condition.

SDA connected to SDA

SCL connected to SCK

#include <SPI.h>

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

#define OLED_RESET 4

Adafruit_SSD1306 display (OLED_RESET);

#define NUMFLAKES 10

#define XPOS 0

#define YPOS 1

#define DELTAY 2

#define LOGO16_GLCD_HEIGHT 16

#define LOGO16_GLCD_WIDTH 16
38

static const unsigned char PROGMEM logo16_glcd_bmp[] =

{ B00000000, B11000000,

B00000001, B11000000,

B00000001, B11000000,

B00000011, B11100000,

B11110011, B11100000,

B11111110, B11111000,

B01111110, B11111111,

B00110011, B10011111,

B00011111, B11111100,

B00001101, B01110000,

B00011011, B10100000,

B00111111, B11100000,

B00111111, B11110000,

B01111100, B11110000,

B01110000, B01110000,

B00000000, B00110000 };

#if (SSD1306_LCDHEIGHT != 64)

#endif

const int MQ3=0;//alcohal sensor in analog A0

const int Buzzer=8;//buzzer in pin 8 alcohal

const int LED=9;//disco LED alcohal


39

const int CCW=4;//Ignition relay alcohal

const int buzzerPin = 12;//buzzer fire pin 12

const int flamePin = 11;//buzzer fire input 11

int Flame = HIGH;

int redled = 52;//fire danger

int greenled = 53;// no fire

const int CW=3;//Window motor

const int coll = 41;//eye sensor

const int coled =50;//eye sensor output LED

const int buz=47;//eye sensor buzzer

int limit;

int value;

int buzzer = 30;

long duration;

int distance;

const int trigger Pin = 7;

const int echoPin = 6;

const int LED1 = 22;

const int LED2 = 24;

int buzz1 = 31;

long duration1;

int distance1;

const int trigPin1 = 2;


40

const int echoPin1 = 1;

const int LED11 = 23;

const int LED21 = 25;

void setup()

{ // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)

display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D

(for the 128x64)

// init done

// Show image buffer on the display hardware.

// Since the buffer is intialized with an Adafruit splashscreen

// internally, this will display the splash screen.

display.display();

delay(2000);

// Clear the buffer.

display.clearDisplay();

pinMode(coll,INPUT);

pinMode(coled, OUTPUT);

pinMode(buz, OUTPUT);

pinMode(flamePin, INPUT);

pinMode(redled, OUTPUT);
41

pinMode(greenled, OUTPUT);

pinMode(CW, OUTPUT);

pinMode(buzzerPin, OUTPUT);

pinMode(MQ3, INPUT);

pinMode(Buzzer, OUTPUT);

pinMode(LED, OUTPUT);

digitalWrite(Buzzer,LOW);

digitalWrite(LED,LOW);

pinMode(CCW, OUTPUT);

// front Collision

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(LED1, OUTPUT);

pinMode(LED2, OUTPUT);

// back Collision

pinMode(trigPin1, OUTPUT);

pinMode(echoPin1, INPUT);

pinMode(LED11, OUTPUT);

pinMode(LED21, OUTPUT);

Serial.begin(9600);

}
42

// the loop function runs over and over again forever

void loop()

{ // Clears the trigPin

digital Write(trigPin, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds

duration = pulseIn(echoPin, HIGH);

// Calculating the distance

distance= duration*0.034/2;

// Prints the distance on the Serial Monitor

if(distance <= 50 && distance >= 20)

{ digitalWrite(LED1, HIGH);

// turn the LED on (HIGH is the voltage level) }

else

{ digitalWrite(LED1, LOW);
// turn the LED off by making the voltage LOW
// wait for a second }
43

if(distance <= 20)

{ digitalWrite(LED2, HIGH);

tone(buzz, 2000);

delay(100);

noTone(buzz);

delay(100);

tone(buzz, 2000);

delay(100);

noTone(buzz);

delay(100);

tone(buzz, 2000);

delay(100);

noTone(buzz);

tone(buzz, 2000);

delay(100);

noTone(buzz);

delay(100);}

else

{ digitalWrite(LED2, LOW);

// turn the LED off by making the voltage LOW

// wait for a second }


44

// Clears the trigPin1

digitalWrite(trigPin1, LOW);

delayMicroseconds(5);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin1, HIGH);

delayMicroseconds(15);

digitalWrite(trigPin1, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds

duration = pulseIn(echoPin1, HIGH);

// Calculating the distance

distance= duration*0.034/2;

if(distance <= 50 && distance >= 20)

{ digitalWrite(LED11, HIGH);
// turn the LED on (HIGH is the voltage level) }

else

{ digitalWrite(LED11, LOW);
// turn the LED off by making the voltage LOW
// wait for a second }

if(distance <= 20)


{ digitalWrite(LED21, HIGH);
45

tone(buzz, 2000);

delay(100);

noTone(buzz);

delay(100);

tone(buzz, 2000);

delay(100);

noTone(buzz);

delay(100);

tone(buzz, 2000);

delay(100);

noTone(buzz);

tone(buzz, 2000);

delay(100);

noTone(buzz);

delay(100); }

else

{ digitalWrite(LED21, LOW);
// turn the LED off by making the voltage LOW
// wait for a second }

//value= analogRead(AOUTpin);

//reads the analaog value from the alcohol sensor's AOUT pin

//Serial.println(value);
46

// text display tests

display.clearDisplay();

display.setCursor(0,0);

display.setTextSize(1);

display.setTextColor(WHITE);

Serial.print("IRSensorip ");

Serial.println(digitalRead(coll));

value= analogRead(MQ3);

Serial.println(value);

Flame = digitalRead(flamePin);

if (Flame== LOW)

{ Serial.println("Fire");
display.println(" FIRE");

digitalWrite(buzzerPin, HIGH);

digitalWrite(redled, HIGH);

digitalWrite(greenled, LOW);

digitalWrite(CW, LOW); }

else

{ Serial.println("NO fire");

display.println("No Fire");

digitalWrite(buzzerPin, LOW);

digitalWrite(greenled, HIGH);
47

digitalWrite(redled, LOW);

digitalWrite(CW, HIGH); }

if (digitalRead(coll)==LOW)

{ Serial.println("Sleep");

display.println("Sleeping");

digitalWrite(coled,HIGH);

digitalWrite(buz,HIGH); }

else
{ Serial.println("Awake");

display.println("Awaked");

digitalWrite(coled,LOW);

digitalWrite(buz,HIGH); }

if(value>600)

{ Serial.println(value);

display.println("DRUNK ");

digitalWrite(Buzzer,HIGH);

digitalWrite(LED,HIGH);

digitalWrite(CCW, HIGH); }

else

{ Serial.println(value);

display.println("SOBER");

digitalWrite(Buzzer,LOW);
48

digitalWrite(LED,LOW);

digitalWrite(CCW, LOW); }

display.display();

delay (500);
}

3.2 Programming Code-2

#include<Wire.h>
#include <SoftwareSerial.h>
#include <TinyGPS.h>
SoftwareSerial gsmk(7, 11);
TinyGPS gps;
SoftwareSerial ssk(12, 10);

//char c;
float flat=0;
float flon=0;
char phone_no1[] = "03323050346";
const int MPU_addr=0x68;
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
int minVal=265;
int maxVal=402;

double x;
double y;
double z;

int shk;
int shockPin 1= 4; // Pin 4 Input
int shockVal1 = HIGH; // Shock measurement
49

boolean bAlarm = false;


unsigned long lastShockTime; // Measured a shock
int shockAlarmTime = 250;

void setup()
{
Serial.begin(9600);
ssk.begin(9600);
gsmk.begin(9600);

pinMode (shockPin1, INPUT) ; // input KY-031


Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true); }

void loop ()
{
shock();
if(shk==1)
{ digitalWrite(13,HIGH);
delay(500);
gpsdata();
delay(500);
angle();
delay(500);
sms();
digitalWrite(13,LOW); }
}

void shock()
{ shockVal1 = digitalRead (shockPin1) ; // read the value from our sensor
50

if (shockVal 1== LOW) // If we're in an alarm state


{ lastShockTime 1= millis(); // record the time of the shock
Serial.println(lastShockTime1);
// The following is so you don't scroll on the output screen

if (!bAlarm)
{ Serial.println("ACCIDENT!");
Serial.println("-----------------------------------------");
bAlarm = true;
shk=1; }
}
else
{
// if( (millis()-lastShockTime) > shockAlarmTime && bAlarm){
// Serial.println("no alarm");
bAlarm = false;
shk=0;
}
}

void angle()
{
Wire.beginTransmission(MPU_addr);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true);
AcX=Wire.read()<<8|Wire.read();
AcY=Wire.read()<<8|Wire.read();
AcZ=Wire.read()<<8|Wire.read();
int xAng = map(AcX,minVal,maxVal,-90,90);
int yAng = map(AcY,minVal,maxVal,-90,90);
int zAng = map(AcZ,minVal,maxVal,-90,90);
51

x= RAD_TO_DEG * (atan2(-yAng, -zAng)+PI);


y= RAD_TO_DEG * (atan2(-xAng, -zAng)+PI);
z= RAD_TO_DEG * (atan2(-yAng, -xAng)+PI);

Serial.print("AngleX= ");
Serial.println(x);

Serial.print("AngleY= ");
Serial.println(y);
Serial.print("AngleZ= ");
Serial.println(z);
Serial.println("-----------------------------------------");
delay(200);

if(x>150 && x<200)


{text="ACCIDENT HAPPENED AND CAR HAS TILTED AT LOCATION "; }
else
{text="ACCIDENT HAPPENED AT LOCATION "; }

void gpsdata()
{
ssk.listen();
Serial.println("getting data");
bool newData = false;
unsigned long chars;
unsigned short sentences, failed;

// For one second we parse GPS data and report some key values
for (unsigned long start = millis(); millis() - start < 1000;)
{
while (ssk.available())
{ char c = ssk.read();
52

Serial.write(c); // uncomment this line if you want to see the GPS data flowing
if (gps.encode(c)) // Did a new valid sentence come in?
newData = true;
}
}

if (newData)
{ float flat, flon;
unsigned long age;
gps.f_get_position(&flat, &flon, &age);
Serial.print("LAT=");
Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
Serial.print(" LON=");
Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
Serial.print(" SAT=");
Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
Serial.print(" PREC=");
Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop()); }

gps.stats(&chars, &sentences, &failed);


Serial.print(" CHARS=");
Serial.print(chars);
Serial.print(" SENTENCES=");
Serial.print(sentences);
Serial.print(" CSUM ERR=");
Serial.println(failed);

if (chars == 0)
{ Serial.println("** No characters received from GPS: check wiring **"); }

void sms()
{ gsmk.listen();
Serial.println("SENDING THE SMS");
53

Serial.println(text);
Serial.println(flat,6);
Serial.println(flon,6);
gsmk.print("AT+CMGF=1\r");
delay(400);
gsmk.print("AT+CMGS=\"");
gsmk.print(phone_no1);
gsmk.println("\"");
delay(300);
gsmk.println(text);
gsmk.print("http://maps.google.com/?q=");
gsmk.print(flat, 6);
gsmk.print(",");
gsmk.print(flon, 6);
delay(200);
gsmk.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(200);
gsmk.println();
delay(1000);
Serial.println("SENT");
}
54

3.3 Simulation Results

FIRE DETECTION SYSTEM

The fire detection system was installed in a car model and a number of simulation tests were carried out
by using flame sensor for detecting fires in cars. The software used is Arduino which analyses and
complies the code for analyzing and detecting flame. When a fire was lit in front ofthe sensor there was
an immediate response from the sensor and an alarm buzzer was sounded and a light was lit. The
microcontroller receives the data as an input from the flame sensor nodes and displays it on the LCD
screen. Two sets of scenarios were chosen one is of no fire and the other is for fire detection which is
continuously displayed on the LCD screen. The flame sensor takes a Boolean input (0,1) and the next
step is repeat in case the input is 0 that is ‘no fire’. After the microcontroller receives the data, it gives
high pulse to the buzzer circuit and the buzzer is turned on. Continuous testing confirms the ability of the
system to detect sudden fires and the buzzer was efficiently sounded with the LED light with the
probability of 0.98.

As fire is not detected there is no response


55

As fire is detected, LED light is lit and a buzzer is sounded

ANTI-COLLISION SYSTEM

The analysis and simulation testing is done using ultrasonic sensors which are placed in front
and the back of the vehicle so that it can be monitored and controlled from both sides. The
software used for the simulation is Arduino, this software runs the program of the anti-
collision system which is then uploaded to the IC of the microcontroller. The data from the
positioned ultrasonic sensors are collected which hasan approximate range detection stored in
the microcontroller for the detection of objects. The working of the system can be explained
in terms of zones. The zones are divided into three parts. The first part covers the distance of
greater than 50 cm from the sensor, the second part of the zone covers the distance of 20 cm
from the sensor and the third part covers the distance which is less than 20cm. The system has
two led lights blue and red. The blue LED light represents the distance which is less than 50
cm but greater than 20cm from the sensor, while the red light is considered a dangerous zone
which is less than 20cm from the sensor. The ultrasonic sensor monitors the distance of the
object continuously, once an object or an obstacle is detected, it calculates the distance
between the sensor and the object. If the object is within the range of 50 cm and 20cm a red
light is lit to warn the driver, and if the object is in the range of 20 cm or less a blue light is lit
and a buzzer is sounded to warn the driver to take necessary action against possibl collision
occurrence. The testing results are shown below
56
57

AlCOHOL DETECTION SYSTEM

An alcohol detection system consists of MQ-3 sensor which detects the presence of alcohol in the
air. The sensor is attached to the left and right side of the driver seat. If the driver has consumed
alcohol, the sensor detects the ethanol molecules in air sends a signal to the microcontroller which is
58

the brain of the system in the Arduino. The software used in this system in Arduino which compiles
the C language program of the system and uploads it to the microcontroller. We tested the efficiency
of the system by spraying a perfume to stimulate the response of alcohol concentration.The system
can be divided in 3 units:
Indication: LED light and a buzzer is used as indication of presence of alcohol. When the sensor
detects the presence of alcohol it sends a voltage signal to the microcontroller which in turn gives a
signal to the circuit and as a result the LED is lit and a buzzer is sounded.
DISPLAY: a LCD screen is used to display whether the driver has an alcohol consumption or not.
The LCD is powered by Arduino which is connected to the Arduino.
RELAY SWITCH: if the system does not meet the fitness threshold value of the driver than the
microcontroller takes action and switches of the relay switch which shuts down the engine of the
driver that is the ignition system is turned off.
59

ANTI-SLEEP SYSTEM

Since we have discussed earlier that IR sensor activates when an obstacle is placed within its range.
The sensor mounted on a glass is monitoring the eye blinking. Soon as the eye blinks, it acts as an
obstacle for the sensor and a buzzer will beep after a delay of 3 seconds. Simulation results have
shown below.

Before After 3 seconds, LED will blink


60

VEHICLE DETECTION SYSTEM

Since we have discussed earlier that there is a shock sensor and accelerometer embedded in it, the
GSM module will send an emergency message to the predefined number with location. The results
are attached below.
61

CHAPTER-4
COST ANALYSES, FUTURE WORK AND CONLUSION

4.1 COST ANALYSES

ITEM # COMPONENT QUANTITY COST (Rs)


1 Arduino Mega 1 1100
2 Arduino Nano 1 600
3 MQ3 Sensor 1 300
4 Fire Sensor 1 200
5 Ultra Sonic Sensor 2 700
6 IR Sensor 1 100
7 OLED 1 1000
8 9V Recharge Battery 2 1200
9 Relay 1 200
10 GSM 800L 1 900
11 KY031 Shock Sensor 1 200
12 GYNEO GPS Module 1 500
13 MPU-6050 Module 1 300
14 Safety Goggles 1 350
15 GSM Registration 1 2000
14 4G SIM Card 1 100
15 Wooden Frame design 1 10,000
16 Jumpwires+Jacks+etc Bulk 1000
17 Report Print + Banner 1 4000

TOTAL 24,750
62

4.2 FUTRE WORK

There are lots of areas in this safety module which can be improved further and can be
applied with more sophisticated or mature approach. In vehicle detection feature, the emergency
message can be conveyed directly to the rescue services (in nearby proximity) instead to the third
party. Whereas, wearing a complete anti sleep goggle can be feasible but moreover can be a hassle.
We can mount the IR sensor with limited proximity (should only monitor the eye) on a steering
wheel or sunlight visor. The anti-fire system can also be further improved through the idea of
installing mini fire extinguisher cylinders with auto control. Therefore, there are many ways through
which we can improve this module. We have plans to make it a much better example which can
compete in the automobile industry.

4.3 CONCLUSION

In this modern era of fast growing technology, safety is the most important and key factor
that can’t be neglected. We can rather say the whole technological market relies on safety
precautions. The automobile industry in Pakistan controls a wide market for multiple car variants auto
and manual both. Unfortunately, the safety bracket is often ignored and neglected. Hence we believe
that a little more improvement and a mature approach towards “CAR DRIVER SAFETY DEVICE”
will lead to many safety problem solutions. We can conclude that combining various approaches or
methods can provide exciting and more robust results to create a safer environment.
63

REFERENCES

 http://www.physics.org/
 Drivers with Automatic Car Engine Locking System.
 http://www.diva-portal.org/smash/get/diva2:962827/FULLTEXT01.pdf
 Kavish Atul Sanghvi,Mukesh. Drunk Driving Detection, Patel School of
Technology,Management and Engineering, India
 https://create.arduino.cc/projecthub/Vijendra/arduino-based-collision-detection-warning-
system-d1beec
 https://pdfs.semanticscholar.org/020b/c4a1bdd27d53016e23830cd0a3323072eaec.pdf
 https://www.irjet.net/archives/V4/i12/IRJET-V4I12227
 http://www.ijsdr.org/papers/IJSDR1706041
 https://github.com/BSP-Embed/Drowsy-Driver-Detection
 https://lastminuteengineers.com/sim800l-gsm-module-arduino-tutorial/

Potrebbero piacerti anche