Driver Drowsiness Detection System

Published Jul 17, 2024
 168 hours to build
 Intermediate

A Driver Drowsiness Detection system using raspberry pi, open cv ,pi cam ,Arduino,ADXL and eeg sensor.

display image

Components Used

Raspberry Pi 4 - 4GB
Single Board Computers Raspberry Pi 4 4GB
1
Arduino UNO
Arduino UNO
1
Raspberry Pi Camera with Module
Cameras & Camera Modules Camera Module 3 Wide
1
ADXL345 Digital Accelerometer
ADXL345 Digital Accelerometer ADXL345 Digital Accelerometer
1
AD8232 Heart rate monitor
AD8232 is a single-lead heart rate monitor.
1
Piezo Buzzers
Piezo Buzzers & Audio Indicators buzzer, 14 mm Round, 6.7 mm deep, 10 Vp-p, 80 dB, Through Hole, Piezo Audio Transducer
1
LM324 Quad Op Amps
Operational Amplifiers - Op Amps Quad
1
Description

SOFTWARE AND HARDWARE INTEGRATION(WORKING)

CAM MODULE ,  RASPBERRY PI AND BUZZER

  • Initially we are taking the values from the Raspberry pi CAM and feeding it into Raspberry pi 4 thonny ide . Here the processing of the live video feed is done where first the face of the user is detected by haarcascade_frontalface_default.xml. After the face detection is done using shape_predictor_68_face_landmarks.dat the face is divided into 68 landmarks.
  • After successfully dividing the face into 68 points the EAR and YAWN threshold is calculated . The EAR is eye aspect ratio which detects if the eye is closed . We have also put a timer of 3 sec to differentiate between blinking and sleeping
  • The Yawn threshold is nothing but the distance between upper and lower lip which is used to detect yawn the yawn threshold is adjusted such that it differentiates between yawning and talking
  • In case any of the YAWN ALERT or DROWSINESS ALERT is raised the alarm or in our case the buzzer pin goes HIGH in order to alert the asleep driver

 

ADXL345 and RASPBERRY PI

  • With ADXL345 we are trying to map the normal behavior of the steering wheel when the driver is awake i.e the acceleration of the steering wheel will be normal levels
  • Where as in case of an asleep driver he/she may be changing lanes suddenly hence the acceleration of the wheel of will be more . This is based of the techniques used in cars such as XUV500.
  • We have initially connected the adxl345 with the Raspberry pi using I2C which means the connection has been made using SCL and SDA pins. While the sensor is powered using 3.3 V .
  • SMBUS is used to connected and communicate the Raspberry pi with the I2C devices , which includes the read and write commands
  • Initially I2C device was detected i2cdetect -y 1 and the slave address 0x53D was given as the output on the terminal.First the device is put in measurement mode .After that the ADXL345 was put into read mode . After which the data of acceleration of X, Y , Z axes was taken and if the X axes was more than ms2 a warning signal is printed showcasing irregular behavior.

 

ARDUINO and AD8232

  • AD8232 is a device that acquire, amplify and compare the weak electrical signals generated by the brain during . It is particularly sensitive to the low-amplitude signals associated with EEG measurements. It is the on the basis of the waveform patterns generated the by EEG signal that helps understand the sleep condition. It is using these waves we are trying to figure out the condition in case of an asleep person and the condition in case of awake person
  • The AD8232 patches are first connected above the RIGHT Eye ,  Center of the forehead, LEFT Eye, then the connections are done to arduino with the SDN, LO +, LO- , OUTPUT, 3.3V and GROUND

1.  EEG Signal Processing:

 Adjust the circuit to process EEG signals instead of ECG. The AD8232 output, originally hovering around 1.5 volts DC, will now reflect EEG activity.

2.  Extended Wink Detection:

Modify the comparator thresholds to detect prolonged winking indicative of sleep-related behavior.

       Left-eye winking raises the output waveform towards 3.3 volts. Adjust the threshold accordingly.

        Right-eye winking lowers the output waveform towards zero volts. Adjust this threshold as well.

 

CIRCUIT DIAGRAM 



Modifications made in AD8232


 


 

Connection of AD8232 with LM324N ic and arduino uno


 Output

Picture showcasing sleepy eye and yawn being detected and the alert is shown with red color

 

The DLIB 68 points mask mapping the face into the points
 

Values of the ADXL345 sensor being taken using Raspberry pi for further analysis


 

Glowing of the on board led on closing of eye for a long time( won’t work for normal blink of the eye)
 

VIDEO DEMONSTRATION OF THE RESULTS

 

Codes

Downloads

Circuit Diagram and Results Download
Comments
Ad