An end-to-end IoT system for sleep analysis, featuring a custom-designed wearable, a secure BLE protocol, and on-device Machine Learning inference.
Engineering Goal: Bridge the gap between low-level hardware constraints and high-level software scalability by creating a full-stack pipeline from raw sensor acquisition to user-facing analytics.
The system follows a data streaming architecture. A low-power wearable device handles raw data acquisition, while a companion iOS application manages the heavy lifting: signal processing, ML inference, and visualization.
- Sensing: Accelerometer (FXOS8700) & Heart Rate sensor capture raw data.
- Transmission: ESP32 microcontroller streams data packets via Bluetooth Low Energy (BLE).
- Processing: iOS App aggregates data into rolling windows (Feature Engineering).
- Inference: A Core ML model (
PulseClassifier) classifies the state asAwakeorAsleep.
├── hardware/ # PCB Design files (Altium/KiCad exports)
│ ├── schematics/ # 2D/3D Renders and Schematics
│ └── assembly/ # Assembly drawings and BOM
├── ios-app/ # iOS Companion App (Swift, SwiftUI, CoreML)
├── src/ # Python Codebase
│ ├── data/ # Data loading and cleaning scripts
│ ├── models/ # XGBoost training logic
│ └── scripts/ # Pipeline orchestration scripts
├── models/ # Serialized models (.joblib, .onnx)
├── notebooks/ # Jupyter Notebooks for EDA
└── images/ # Documentation assets
Role: Raw Data Acquisition & Transmission Status: Design complete, Ready for Fabrication.
-
Microcontroller: ESP32-WROOM-32E. Selected for its dual-core architecture and deep sleep capabilities tailored for battery-operated IoT.
-
Sensors:
-
FXOS8700CQR1: 6-axis Accelerometer/Magnetometer for precise motion tracking.
-
Heart Rate Sensor: Dedicated photoplethysmography (PPG) IC for pulse wave sensing.
-
Power Management: USB-C charging circuit with dedicated voltage regulation (LDOs) to ensure stable power delivery.
The PCB utilizes a two-sided component placement strategy to optimize for size and signal integrity:
- Top Side (Digital Domain): Houses the ESP32, USB-C connector, and power management ICs. This isolates high-frequency digital noise.
- Bottom Side (Analog/Sensor Domain): Dedicated to the Heart Rate sensor to ensure direct skin contact and clean analog signal acquisition.
| 3D Render (Top) | Electronic Schematic |
|---|---|
Design Choice: The physical separation of the analog sensor (Bottom) from the noisy digital logic (Top) minimizes signal interference, crucial for accurate biometric readings.
Role: Classification Algorithm Stack: Python, Scikit-Learn, XGBoost
The core logic is a supervised learning model trained on the MMASH dataset.
- Feature Engineering: Raw data is converted into 11 statistical features over rolling windows (1, 5, and 15 minutes).
- Examples:
hr60_mean,vm15_std(Vector Magnitude Standard Deviation).
- Model Selection: Compared Logistic Regression, Random Forest, and XGBoost.
- Final Model: Tuned XGBoost Classifier.
- Performance: 93% Accuracy, 0.96 F1-Score (Awake).
- Optimization: Hyperparameters tuned via
RandomizedSearchCV.
Role: Client, Processor & Visualizer Stack: Swift, SwiftUI, Charts, Core ML
- Real-time BLE: Handles scanning and parsing of the standard Heart Rate Service (UUID
0x180D). - On-Device Inference: The Python-trained XGBoost model was converted to
.mlpackageto run locally on the iPhone, ensuring privacy and offline capability. - UI/UX: "Deep Night" aesthetic with interactive, scrubbable charts.
- Hardware: Pulse PCB or ESP32 dev kit.
- Software: Xcode 15+, Python 3.9+.
To reproduce the model training or explore the notebooks:
pip install -r requirements.txt
cd src/models
python train_final.py
- Open
ios-app/Pulse app.xcodeprojin Xcode. - Ensure
PulseClassifier.mlpackageis linked in the Build Phases. - Run on a physical iPhone (Bluetooth required).
precision recall f1-score support
False 0.99 0.93 0.96 4893
True 0.76 0.95 0.85 1182
accuracy 0.93 6075
Noé Cornu - Computer Engineering Student @ EPITA