This project detects whether a rider is wearing a helmet using a Raspberry Pi and a TensorFlow Lite model. It also integrates an MPU6050 accelerometer to check if the vehicle is moving. If a rider is detected without a helmet while the vehicle is moving, an alert buzzer sounds.
- Helmet Detection using a TFLite model and Raspberry Pi camera.
- Vehicle Motion Detection using an MPU6050 accelerometer.
- Relay Control to enforce helmet usage before vehicle ignition.
- Buzzer Alert when the vehicle is moving without helmet detection.
- Raspberry Pi 4 / 3B+ (Any model with GPIO support)
- Raspberry Pi Camera Module
- MPU6050 Accelerometer Module
- 5V Relay Module
- Buzzer
- Connecting Wires
| Component | Raspberry Pi Pin |
|---|---|
| Buzzer | GPIO 18 (Pin 12) |
| Relay | GPIO 17 (Pin 11) |
| MPU6050 SDA | GPIO 2 (Pin 3) |
| MPU6050 SCL | GPIO 3 (Pin 5) |
| MPU6050 VCC | 3.3V (Pin 1) |
| MPU6050 GND | GND (Pin 6) |
Ensure your Raspberry Pi is updated:
sudo apt update && sudo apt upgrade -yThen, install the required Python packages:
pip install -r requirements.txtRun:
sudo raspi-config- Navigate to
Interfacing Options - Enable
I2C - Reboot the Pi:
sudo reboot
After setting up the hardware, run the detection script:
python helmet_new.py- If a helmet is detected, the relay remains ON.
- If no helmet is detected and the vehicle is moving, a buzzer alert sounds.
- If no helmet is detected but the vehicle is stationary, the relay turns OFF.
- Ensure the model file
helmet.tfliteis placed in the same directory ashelmet_detection.py. - You can modify the relay behavior based on your requirements.
This project is open-source under the MIT License.