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.
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 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 the ADXL345 module.import Adafruit_ADXL345
# Create an ADXL345 instance.
accel = Adafruit_ADXL345.ADXL345()
I used the above modules.
# Read the X, Y, Z axis acceleration values
x, y, z = accel.read()
if x > 500or y > 500or z > 500: #500 is the number that the values go above in all my crash testsprint('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.
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.