Introduction: Crash Detection Module Based on MPU6050 and Raspberry Pi Pico

This is a project based on accelerometer to detect and alert the in event of a vehicle crash or accident.

Supplies

Raspberry Pi Pico

MPU6050 module

Active Buzzer

Breadboard

Solid core wires

Micro USB cable

Step 1: Do the Wiring As Shown in the Schematics

Do the wiring and note the GPIO pins you are using for later use in writng code

Step 2: Install Thonny and Configure It for Programming Pi Pico

Install thonny from provided link from here

Step 3: Configure Raspberry Pi Pico

Hold the bootsel button while connecting raspberry to the computer.Open thonny and go tools> options>interpreter>micropython(raspberry pi pico)

Step 4: Upload the Code and Enjoy :)

from imu import MPU6050
import time
from machine import Pin, I2C


i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
imu = MPU6050(i2c)
buzzer = Pin(16, Pin.OUT)


ax=[0,0]
ay=[0,0]
az=[0,0]


while True:

    
        ax[0]=(imu.accel.x)
        ay[0]=(imu.accel.y)
        az[0]=(imu.accel.z)
        ax[1]=(imu.accel.x)
        ay[1]=(imu.accel.y)
        az[1]=(imu.accel.z)


        if abs(ax[0]-ax[1])>1 or abs(ay[0]-ay[1])>1 or abs(az[0]-az[1])>1 :


            buzzer.toggle()
            time.sleep(0.1)
            buzzer.toggle()


        print(abs(ax[0]-ax[1]), abs(ay[0]-ay[1]),abs(az[0]-az[1]))

Step 5: Read the Report for More Information