End-to-End ESP32 + Raspberry Pi IoT Safety Wearable, Real-Time ML Risk Scoring, 100 Hz Fall Detection & Live Flask Dashboard
LifeLine is a multi-worker industrial safety & biometric monitoring platform built around an ESP32-equipped Smart Safety Jacket and a Raspberry Pi Edge AI hub. It combines deterministic 100 Hz IMU fall detection on the wearable with real-time MQTT telemetry, rolling-window machine learning risk classification, ThingSpeak cloud logging, and a Chart.js live monitoring web dashboard.
βββββββββββββββββββββββββββββ esp32/sensor_data (1 s) βββββββββββββββββββββββββββββββββββββββββββββ
β ESP32 Smart Jacket β ββββββββββββββββββββββββββββββββΊ β Raspberry Pi Edge Hub β
β β esp32/fall_event (instant) β β
β β’ MAX30102 Heart Rate β ββββββββββββββββββββββββββββββββΊ β β’ processor.py βββΊ health_monitor_log.csv β
β β’ MPU6050 6-Axis IMU β β βββΊ ThingSpeak (15 s) β
β β’ MQ Gas Sensor (GPIO 34) β pi/risk/<WORKER_ID> β β’ live_inference.py (ML Risk + Man-Down) β
β β’ WS2812B LED + Buzzer β ββββββββββββββββββββββββββββββββ β β’ dashboard.py (Flask :5000) β
βββββββββββββββββββββββββββββ LOW / MEDIUM / HIGH / FALL βββββββββββββββββββββββββββββββββββββββββββββ
| Module | Path | Description |
|---|---|---|
| ESP32 Firmware | iot_esp32/ |
Non-blocking Arduino/ESP32 sketch (smart_jacket.ino), 100 Hz FallDetector.h, and standalone C++17 unit tests (test_fall_detector.cpp). |
| Raspberry Pi Edge AI Hub | iot_pi/ |
Complete edge stack: MQTT ingest (processor.py), rolling 20 s ML feature extractor (features.py), risk classifier & anomaly detector (predictor.py, live_inference.py), multi-worker Flask dashboard (dashboard.py), training pipeline (train_models.py), and systemd services. |
| Standalone Dashboard | health-dashboard/ |
Lightweight drop-in Flask + offline Chart.js (chart.umd.min.js) web UI reading health_monitor_log.csv directly. |
| Peripheral | Interface / Pin | Purpose |
|---|---|---|
| MAX30102 | I2C (SDA 21, SCL 22) |
Heart rate (avg_bpm) & finger-on-sensor detection |
| MPU6050 | I2C (SDA 21, SCL 22) |
100 Hz 6-axis acceleration (Β±16 g), gyro, and chip temperature |
| MQ Gas Sensor | Analog (GPIO 34) |
Ambient gas concentration monitoring (warn β₯ 2000, danger β₯ 3000) |
| WS2812B RGB LED | Digital (GPIO 13) |
Visual ML risk status (Green LOW, Yellow MEDIUM, Red HIGH, Fast Blink FALL) |
| Buzzer | Digital (GPIO 23) |
Audible alert on HIGH risk and FALL / MAN DOWN events |
- Open
iot_esp32/smart_jacket/smart_jacket.inoin Arduino IDE (ESP32 Dev Module). - Configure
ssid,password,mqtt_server(Pi IP), andWORKER_IDbefore flashing. - Run the C++17 fall-detector verification tests on PC:
g++ -std=c++17 -o test_fd iot_esp32/tests/test_fall_detector.cpp && ./test_fd
cd iot_pi
bash install.sh # Installs apt packages, Mosquitto MQTT broker & checks/trains ML models
bash run_all.sh # Starts processor.py, live_inference.py, and dashboard.py (:5000)Optional: run as background boot services with bash install_services.sh.
To export ThingSpeak / MQTT secrets safely:
export THINGSPEAK_API_KEY="your_write_api_key"
export MQTT_PASSWORD="your_mqtt_password"- Creator & Lead Engineer: Dhayananth J (
@0-Name-Alex) β’ dhayananth.me - Collaborators: Devarasetty Kuldeep (
@DevarasettyKuldeep) Β·@Anbu-KK
Licensed under the MIT License.
