A Raspberry Pi used to make a system that would alert a drowsy driver that he is falling asleep using OpenCV image recognition.

Public Chat
Similar projects worth following
The project uses OpenCV image detection to identify wether or not the user is falling asleep. If the user is falling asleep, a loud buzzer alerts the user. It also includes a GPS module, an Accelerometer and a GSM module to detect a car crash and to send an SMS with the location of the crash.

Block Diagram for the project

  • 1 × Raspberry Pi 4
  • 1 × Micro SD card
  • 1 × Micro HDMI cable
  • 1 × Type C cable and power supply of 5v4a
  • 1 × PiCameraV2

View all 8 components

  • Laser cut case finished

    Aryan08/15/2019 at 01:16 0 comments

    After designing the laser cut case and attaching my components to it, I am nearly done with the project. I think it looks pretty cool.

  • Crash Detection woking with interrupts

    Aryan08/10/2019 at 05:50 0 comments

    I finally managed to get the accelerometer to give me an output only when the G force on it crosses a certain threshold using interrupts. I did this by reading the ADXL345's registers.

    The falling edge is the output that came when I shook the accelerometer to depict an impact.

    Now I need to work on sending an SMS when the crash is detected.

  • Reading the Values manually from the ADXL module

    Aryan07/27/2019 at 14:00 0 comments

    Using the smbus module, and the help of my dad, I was able to get the acceleration from the module without using an external library. For some reason I wasn't able to find an online refrence for using the Interrupt pins on the ADXL module. So afr I'm getting value but some problem causes it to give me impossible values.

    Fun fact: if that right most value was real we would all be flattened against the surface of the Earth.

    I need to fix that

  • Crash Alert Up and Running

    Aryan07/12/2019 at 01:11 0 comments

    I wired up the Pi to the ADXL345 and tested it and tested the code. It seemed to work fine. The Pi needed the I2C interface to be on preceding a reboot. After that I made a few modifications

    import time
    # Import the ADXL345 module.
    import Adafruit_ADXL345
    # Create an ADXL345 instance.
    accel = Adafruit_ADXL345.ADXL345()

    I used the above modules.

    while True:
        # Read the X, Y, Z axis acceleration values
            x, y, z =
            if x > 500 or y > 500 or z > 500: #500 is the number that the values go above in all my crash tests
                    print('crash alert')
        # Wait half a second and repeat.

    This is the code I used.

    The output was the words "crash alert" showing up when I shake the ADXL345 module.

    This was detected because after testing I found that in which ever angle you shake it, the X, Y, or Z value went above 500. When an actual crash happens, the entire thing would shake the same way. So I used this method to get the crash alert. 

  • Got the Raspberry Pi 4 working with my code

    Aryan07/09/2019 at 01:09 0 comments

    I got the Raspberry Pi 4 setup with the Raspbian OS. So I connected up the PiCamera v2 and started working. The audio out was through wired earphones, and I finally got the drowsiness detection working!!!

    Now I need to begin work on the next part of my project which is detecting a car crash.

    I wonder how I'm going to test that...

  • Got the Drowsiness detection working

    Aryan07/04/2019 at 12:09 0 comments

    After learning some OpenCV programming I was able to create a system where it detects when a user is falling asleep and plays a sound.

    I will start working on getting the system to detect crashes soon

View all 6 project logs

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates