A machine learning project for estimating blood pressure from PPG (Photoplethysmography) and ECG (Electrocardiography) signals using deep learning techniques. This project implements CNN-LSTM architecture with attention mechanisms for non-invasive blood pressure prediction.
- Real-time BP monitoring with web interface
- Dual signal quality validation (PPG + ECG)
- Intelligent prediction gating (requires ≥60% signal quality)
- Independent signal normalization for accurate predictions
- WebSocket-based streaming for real-time data
- Raw signal filtering in Python for flexibility
Required:
- ESP32 development board
- MAX30102 PPG sensor (pulse oximeter)
- AD8232 ECG sensor module
- 3x disposable ECG electrodes
See HARDWARE_SETUP.md for complete wiring guide with diagrams.
# Start everything with one command
./bash/start-realtime-bp.sh
# Or with custom serial port
./bash/start-realtime-bp.sh /dev/ttyACM0Then open http://localhost:3000 in your browser.
Hardware Setup:
- ESP32 + MAX30102 - See esp32/README.md
- Upload the filtered PPG sketch to ESP32
- Connect MAX30102 sensor and place finger on it
Software:
# 1. Start the bridge server (connects ESP32 → Model → Frontend)
python bridge_server.py --serial-port /dev/ttyUSB0
# 2. In another terminal, start frontend
cd frontend
pnpm dev
# 3. Open browser
open http://localhost:3000See REALTIME_SETUP.md for complete setup guide.
For development and testing, you can use the mock ESP32 server:
# Install Python dependencies
pip install -r requirements.txt
# Start the mock ESP32 WebSocket server
python mock_esp32_server.pyThe server will start on http://localhost:8080 and provide:
- WebSocket endpoint at
ws://localhost:8080/signals - Web interface at
http://localhost:8080 - Real-time PPG and ECG signal simulation
cd frontend
npm install
# or
pnpm install
# Start the development server
npm run dev
# or
pnpm devThe frontend will be available at http://localhost:3000.
The system uses WebSocket connections to stream real-time physiological signals:
{
"type": "signal_data",
"payload": {
"timestamp": 1640995200000,
"ppg_value": 0.5,
"ecg_value": 0.2,
"sample_rate": 250,
"quality": 0.85,
"heart_rate": 72
}
}Note: quality ranges from 0.0 to 1.0 and represents combined PPG+ECG signal quality. Predictions require quality ≥ 0.6.
{
"type": "bp_prediction",
"payload": {
"sbp": 118.3,
"dbp": 78.2,
"timestamp": 1640995200000,
"confidence": 0.87,
"prediction_count": 42,
"error": "Low signal quality - check sensor connections" // Optional, if quality too low
}
}{
"type": "control",
"command": "start_acquisition" | "stop_acquisition" | "calibrate"
}If you see WebSocket errors in the console:
- Check if the backend server is running: Make sure
python mock_esp32_server.pyis running - Verify the connection URL: The frontend should connect to
ws://localhost:8080/signals - Check network connectivity: Ensure no firewall is blocking the connection
- Review browser console: Look for detailed error messages with troubleshooting tips
The project uses the following data structure:
data/raw/- Raw dataset files downloaded from PulseDBdata/processed/- Preprocessed .mat files ready for trainingcheckpoints/- Model checkpoints and saved weights