Crash Detection Module Based on MPU6050 and Raspberry Pi Pico

by virentanti in Circuits > Raspberry Pi

618 Views, 1 Favorites, 0 Comments

Crash Detection Module Based on MPU6050 and Raspberry Pi Pico

schematic_final.jpg

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

Supplies

raspberry pi pico.jpg
mpu6050.jpg

Raspberry Pi Pico

MPU6050 module

Active Buzzer

Breadboard

Solid core wires

Micro USB cable

Do the Wiring As Shown in the Schematics

schematic_final.jpg

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

Install Thonny and Configure It for Programming Pi Pico

Install thonny from provided link from here

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)

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]))

Read the Report for More Information