Repository navigation
Home
This project implements an embedded black box system for accident detection on a Raspberry Pi 3B+.
The system uses an LSM9DS1 inertial measurement unit (IMU) to continuously monitor vehicle movement. Accidents can be detected based on high acceleration or vehicle rollover.
When an accident is detected, the system freezes the recent IMU data stored in a kernel ring buffer, captures an image from a MIPI-CSI camera, displays an SOS message on the Sense HAT LED matrix, and saves the crash data to persistent storage.
The application is divided into three main tasks:
-
Task 1 – IMU and accident detection
Reads accelerometer and gyroscope data at 500 Hz, stores the samples in the kernel ring buffer, and detects impact or rollover events. -
Task 2 – Camera and emergency response
Waits for an accident notification from Task 1, captures the next fresh camera frame, measures the response latency, and displays the SOS message. -
Task 3 – Crash data storage
Waits for crash data from Task 2 and saves the IMU history and camera image to persistent storage.
Task 1 and Task 2 use real-time SCHED_FIFO scheduling, while Task 3 uses the normal Linux SCHED_OTHER scheduling policy.
The system is built around a Raspberry Pi 3B+ and uses:
- LSM9DS1 accelerometer and gyroscope
- MIPI-CSI camera
- Raspberry Pi Sense HAT
- Raspberry Pi 3B+
The project contains several main software components:
- LSM9DS1 userspace driver
- Accident detection algorithm
- Kernel ring buffer for IMU samples
- V4L2 camera capture
- SOS LED matrix output
- Crash data storage
- POSIX threads for the three application tasks