# 🪑 SmartChair AI — Intelligent Posture Monitoring System **Real-time posture classification, spine risk prediction, and adaptive health coaching using IMU + load cell + thermal sensor fusion.** [![Python 3.9+](https://img.shields.io/badge/Python-3.9+-blue.svg)](https://python.org) [![TensorFlow](https://img.shields.io/badge/TensorFlow-2.x-orange.svg)](https://tensorflow.org) [![ESP32](https://img.shields.io/badge/ESP32--S3-Firmware-green.svg)](https://espressif.com) [![AWS IoT](https://img.shields.io/badge/AWS-IoT_Core-yellow.svg)](https://aws.amazon.com/iot-core/) --- ## 🎯 Features | # | Feature | Status | Accuracy/Performance | |---|---------|--------|---------------------| | 1 | **Real-time posture classification** | ✅ | 95.48%+ ML accuracy (ensemble voting) | | 2 | **Long-term spine risk prediction** | ✅ | RULA-based + exponential decay accumulator | | 3 | **Personalised sitting behaviour model** | ✅ | Learns fatigue onset, break patterns per user | | 4 | **Smart micro-break recommendations** | ✅ | Adaptive, score-based urgency (not fixed timer) | | 5 | **Exercise suggestion system** | ✅ | 20+ exercises mapped to specific posture issues | | 6 | **Hybrid sensor fusion** | ✅ | IMU + load cell + thermal (14-channel fusion) | | 7 | **Fatigue & drowsiness detection** | ✅ | CoP variance + micro-movement analysis | | 8 | **Daily/weekly posture score dashboard** | ✅ | 0-100 score with hourly breakdown + trends | | 9 | **Injury risk alert system** | ✅ | Acute + chronic + trend-based alerts | | 10 | **Cloud integration (AWS IoT Core)** | ✅ | MQTT/TLS, DynamoDB, Lambda scoring | | 11 | **Multi-user recognition** | ✅ | Weight signature + k-NN (3-shot enrollment) | | 12 | **Gamification system** | ✅ | Points, streaks, badges, leaderboard | ## 🏗️ System Architecture ``` ┌──────────────────────────────────────────────────────────┐ │ SENSOR LAYER │ │ MPU6050 (50Hz) │ 4× HX711 Load Cells │ AMG8833 │ │ 6-axis IMU │ Weight Distribution │ Thermal │ └────────┬─────────┴──────────┬─────────────┴──────┬───────┘ │ │ │ ▼ ▼ ▼ ┌──────────────────────────────────────────────────────────┐ │ EDGE INFERENCE (ESP32-S3) │ │ Feature Extraction → TFLite INT8 / Random Forest │ │ <30ms inference │ <50KB model │ 14 input channels │ └──────────────────────────┬───────────────────────────────┘ │ UART / Local WiFi ▼ ┌──────────────────────────────────────────────────────────┐ │ INTELLIGENCE LAYER (Raspberry Pi) │ │ │ │ ┌──────────────┐ ┌───────────────┐ ┌──────────────┐ │ │ │ Ensemble │ │ RULA Risk │ │ Fatigue │ │ │ │ Classifier │ │ Scorer │ │ Detector │ │ │ │ (98%+ F1) │ │ (1-7 scale) │ │ (CoP+IMU) │ │ │ └──────────────┘ └───────────────┘ └──────────────┘ │ │ ┌──────────────┐ ┌───────────────┐ ┌──────────────┐ │ │ │ User │ │ Break │ │ Exercise │ │ │ │ Recognition │ │ Engine │ │ Suggester │ │ │ │ (k-NN) │ │ (Adaptive) │ │ (Targeted) │ │ │ └──────────────┘ └───────────────┘ └──────────────┘ │ │ ┌──────────────┐ ┌───────────────┐ ┌──────────────┐ │ │ │ Spine Risk │ │ Gamification │ │ Injury │ │ │ │ Predictor │ │ Engine │ │ Alerts │ │ │ │ (Long-term) │ │ (Points/Bdge) │ │ (3-tier) │ │ │ └──────────────┘ └───────────────┘ └──────────────┘ │ └──────────────────────────┬───────────────────────────────┘ │ MQTT / TLS ▼ ┌──────────────────────────────────────────────────────────┐ │ CLOUD LAYER (AWS) │ │ IoT Core → DynamoDB (telemetry) → Lambda (daily scores) │ │ → SNS (critical alerts) → S3 (raw data backup) │ │ → API Gateway → Dashboard Web App │ └──────────────────────────────────────────────────────────┘ ``` ## 📊 ML Models ### Posture Classifier (Primary) - **Architecture**: Soft-voting ensemble (SVM + DecisionTree + MLP + XGBoost + RandomForest) - **Basis**: [SitPose](https://arxiv.org/abs/2412.12216) (F1=98.2% on 7-class posture) - **Input**: 119 hand-crafted features from 2.56s sliding windows (128 samples @ 50Hz) - **Features**: IMU statistics, FFT spectral features, cross-axis correlations, CoP metrics, load distribution ratios - **Edge deployment**: `micromlgen` → C header for ESP32 (<5KB, <5ms inference) ### MLSTM-FCN (Alternative Deep Model) - **Architecture**: Parallel Conv1D-FCN + LSTM with Squeeze-Excite attention - **Basis**: [MLSTM-FCN](https://arxiv.org/abs/1801.04503) + [FusionActNet](https://arxiv.org/abs/2310.02011) - **Input**: (128, 14) sequential tensor (14 sensor channels × 128 timesteps) - **Edge deployment**: TFLite INT8 quantization (<50KB, <30ms on ESP32-S3) ## 🔧 Hardware (~$110-165 total) See [HARDWARE_BOM.md](HARDWARE_BOM.md) for complete bill of materials and wiring diagram. Key sensors: - **IMU**: MPU6050 (6-axis, I2C, 50Hz) — mounted under seat center - **Load Cells**: 4× 50kg half-bridge with HX711 ADC — at chair corners - **Thermal**: AMG8833 8×8 IR grid — on backrest for presence detection - **MCU**: ESP32-S3 (dual-core 240MHz, 8MB PSRAM, WiFi/BLE) - **Gateway**: Raspberry Pi 4B (complex ML + cloud) ## 🚀 Quick Start ### 1. Install Dependencies ```bash pip install numpy scipy scikit-learn xgboost tensorflow matplotlib pandas joblib ``` ### 2. Run Full Demo (Synthetic Data) ```bash python -m smart_chair.main ``` ### 3. Train Production Model ```python from smart_chair.ml_models.posture_classifier import EnsemblePostureClassifier from smart_chair.data_collection.synthetic_data_generator import generate_dataset, subject_based_split dataset = generate_dataset(n_subjects=20, samples_per_posture_per_subject=500) train, test = subject_based_split(dataset) clf = EnsemblePostureClassifier() clf.train(train["imu_data"], train["load_data"], train["labels"], test["imu_data"], test["load_data"], test["labels"]) clf.save("posture_model.joblib") ``` ## 📁 Project Structure ``` smart_chair/ ├── config/settings.py # All system constants and parameters ├── utils/feature_engineering.py # Feature extraction pipeline (14 channels) ├── data_collection/ │ ├── synthetic_data_generator.py # Physics-based synthetic data │ └── protocol.py # Real data collection procedure ├── ml_models/ │ ├── posture_classifier.py # Ensemble + MLSTM-FCN classifiers │ ├── spine_risk_predictor.py # RULA scorer + fatigue detector + alerts │ ├── user_recognition.py # Multi-user recognition + personalized model │ ├── break_recommendation.py # Adaptive break engine + exercise suggester │ └── gamification.py # Points, badges, streaks, leaderboard ├── cloud/aws_iot_integration.py # MQTT client + AWS infrastructure ├── firmware/esp32_firmware.ino # ESP32-S3 Arduino firmware ├── HARDWARE_BOM.md # Parts list + wiring diagram └── main.py # System orchestrator (Raspberry Pi) ``` ## 📚 Research References | Paper | Contribution | ArXiv | |-------|-------------|-------| | SitPose | Ensemble posture classification (F1=98.2%) | [2412.12216](https://arxiv.org/abs/2412.12216) | | MLSTM-FCN | Multivariate time series architecture | [1801.04503](https://arxiv.org/abs/1801.04503) | | FusionActNet | Static/Dynamic dual-expert IMU classification | [2310.02011](https://arxiv.org/abs/2310.02011) | | SSL-Wearables | Self-supervised pre-training for HAR | [2206.02909](https://arxiv.org/abs/2206.02909) | | UniMTS | Foundation model for IMU (zero-shot) | [2410.19818](https://arxiv.org/abs/2410.19818) | | DULA/DEBA | Differentiable ergonomic assessment | [2205.03491](https://arxiv.org/abs/2205.03491) | | TinyNav | TFLite Micro on ESP32 (<30ms) | [2603.11071](https://arxiv.org/abs/2603.11071) | | AuthentiSense | Few-shot biometric user authentication | [2302.02740](https://arxiv.org/abs/2302.02740) | | Edge Impulse | TinyML MLOps platform | [2212.03332](https://arxiv.org/abs/2212.03332) | ## 📄 License MIT License — Free for personal and commercial use.