elderly fall detection project using Raspberry Pi and IMU sensor data. The system processes accelerometer and gyroscope readings, extracts motion features in real time, trains a machine-learning model, and raises alerts when a fall-like event is detected.
This project matches the resume entry:
Developed ML-based fall recognition using Raspberry Pi and IMU sensor data. Engineered real-time anomaly detection for elderly monitoring applications.
- Reads MPU6050-style IMU streams:
ax, ay, az, gx, gy, gz. - Extracts windowed acceleration, gyroscope, jerk, and posture-change features.
- Trains either a supervised classifier when fall labels are available or an anomaly detector when only normal data is available.
- Supports Raspberry Pi serial monitoring from ESP32/Arduino sensor bridges.
- Replays CSV sensor logs for demos without hardware.
- Logs fall alerts to CSV with timestamp, confidence, and detection reason.
- Includes a separate optional webcam/OpenCV pose demo for computer-vision experimentation.
- Python
- Raspberry Pi compatible runtime
- MPU6050 / IMU sensor data
- Pandas, NumPy, Scikit-learn
- PySerial for live sensor streams
- OpenCV + MediaPipe for the optional vision demo
- Pytest
fall_detection/
imu_features.py # Windowed IMU feature engineering
imu_model.py # Supervised/anomaly ML model wrapper
simulate_imu.py # Generates demo IMU training data
train_imu.py # Trains fall detection model from CSV
monitor_imu.py # Live serial or CSV replay monitoring
alerts.py # CSV alert logging
app.py # Optional webcam pose-based demo
detector.py # Optional pose fall heuristic
tests/
test_detector.py
test_imu_features.py
requirements.txt
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txtGenerate sample IMU data:
python -m fall_detection.simulate_imu --output data/sample_imu.csvTrain the model:
python -m fall_detection.train_imu --input data/sample_imu.csv --output models/imu_fall_model.joblibReplay the CSV as a live stream:
python -m fall_detection.monitor_imu --model models/imu_fall_model.joblib --csv data/sample_imu.csvAlerts are written to:
alerts/imu_fall_alerts.csv
- Connect MPU6050 to ESP32 or Arduino.
- Stream rows over serial in this format:
ax,ay,az,gx,gy,gz
Example:
0.02,0.01,1.01,2.4,-1.2,0.8
- On the Raspberry Pi, run:
python -m fall_detection.monitor_imu --model models/imu_fall_model.joblib --serial-port COM3On Linux/Raspberry Pi, the port usually looks like /dev/ttyUSB0 or /dev/ttyACM0.
Training CSV files should include:
timestamp_ms,ax,ay,az,gx,gy,gz,label
The label column is optional. If labels are present, values such as 1, true, fall, or anomaly are treated as falls. If labels are not present or only one class exists, the project trains an Isolation Forest anomaly detector.
Use webcam pose detection:
python -m fall_detection.app --source 0Use a video file:
python -m fall_detection.app --source path\to\video.mp4pytestFall Detection System for Elderly Care: Developed a Raspberry Pi based ML system for elderly fall recognition using MPU6050 IMU accelerometer and gyroscope data. Engineered real-time windowed features for acceleration magnitude, jerk, posture shift, and angular velocity; trained supervised/anomaly detection models with Scikit-learn; and implemented live serial monitoring with alert logging for safety-critical elderly care workflows.
This is an academic and prototype-grade monitoring system. Production use would require calibrated hardware placement, larger real-world fall/non-fall datasets, privacy and safety validation, caregiver notification integration, and clinical reliability testing.