An open-source Python SDK for connecting, monitoring, and capturing raw physiological and IMU data from Polar BLE devices.
Project description
Polar BLE Python SDK
An open-source Python SDK for connecting, monitoring, and capturing raw physiological and IMU data from Polar BLE devices (H10, Verity Sense, Vantage/Grit watches). The project offers real-time monitoring, machine-learning-based stress detection, a reactive Streamlit dashboard with live waveform charts, and a premium console terminal dashboard with event logging and hotkey markers.
๐ Quick Start
1. Installation & Setup
Requirements: Python 3.8+, Windows 10/11 (Bluetooth capable).
Option A: Package Install from PyPI (Recommended for Library Use)
You can install the core BLE SDK directly from PyPI:
pip install polar-ble-sdk
To install optional features (such as ML predictors or dashboards):
- Install ML training and dependencies:
pip install polar-ble-sdk[ml] - Install Streamlit dashboard dependencies:
pip install polar-ble-sdk[dashboard] - Install all dependencies:
pip install polar-ble-sdk[ml,dashboard]
Option B: Local Repository Install (Recommended for Dashboard/CLI Apps)
Run the automatic setup script in PowerShell to create the virtual environment and install all dependencies:
.\setup.ps1
(Alternatively, configure manually: python -m venv .venv, .\.venv\Scripts\Activate.ps1, pip install -r requirements.txt)
2. Streamlit Dashboard
Verify setup and launch the Streamlit dashboard using:
.\start.ps1
(Manual command: streamlit run src/polar_ble_sdk/app_streamlit.py)
3. Premium Terminal Dashboard
Launch the premium command-line dashboard with real-time event markers, battery monitoring, and 1 Hz CSV data logging:
.venv\Scripts\python.exe scripts\monitor_polar_terminal.py
- Specify Device: Target a specific device (like a Vantage watch) by passing the name or MAC address:
.venv\Scripts\python.exe scripts\monitor_polar_terminal.py --device Vantage
- Hotkey Event Markers: Press
SPACE(marker),S(stimulus_on),B(baseline_start), orR(rest_start) to log markers on-screen and save them directly in the CSV files underdata/.
4. Dual-Device Terminal Dashboard
If you want to monitor both a Polar H10 chest strap and a Polar Verity Sense optical sensor side-by-side simultaneously:
.venv\Scripts\python.exe scripts\monitor_dual_polar.py
- Optional Filters: Specify target devices:
.venv\Scripts\python.exe scripts\monitor_dual_polar.py --h10 "H10 EA396220" --sense "Sense 11781835"
- Separate Logging: Automatically saves independent, conflict-free CSV logs under
data/for each connected device.
๐ Sensor Sampling Frequencies & CSV Logging
1. Device Capabilities (Maximum Sampling Rates)
Polar devices transmit sensor data at high frequencies via their PMD (Physical Measurement Device) service:
- Polar H10:
- ACC (Accelerometer): 25, 50, 100, 200 Hz (Resolution: 16-bit, Range: 2, 4, 8 G)
- ECG (Electrocardiogram): 130 Hz (Resolution: 14-bit)
- Heart Rate / RR-Intervals: Event-driven (per heartbeat, ~1 Hz)
- Polar Verity Sense:
- PPG (Photoplethysmography): 55 Hz (Resolution: 22-bit, Channels: 4)
- ACC (Accelerometer): 52 Hz (Resolution: 16-bit, Range: 8 G, Channels: 3)
- GYRO (Gyroscope): 52 Hz (Resolution: 16-bit, Range: 2000 dps, Channels: 3)
- MAG (Magnetometer): 10, 20, 50, 100 Hz (Resolution: 16-bit, Range: 50 Gauss, Channels: 3)
- HR / PPI (Pulse-to-Pulse / HRV): Event-driven (per pulse, ~1 Hz)
- Polar Smartwatches (Grit X, Vantage, etc.):
- PPG (Photoplethysmography): Natively configured up to 135 Hz (varies by model)
- ACC / GYRO (Kinematics): Configurable up to 208 Hz (varies by model)
2. CSV Logging Rates & High-Frequency Option
- Default 1 Hz Logging: By default, the terminal dashboards (
monitor_polar_terminal.pyandmonitor_dual_polar.py) sample and record data to CSV at 1 Hz. This contains the latest values at each second boundary. This downsampling prevents the creation of extremely sparse CSV files that result from mixing different sampling rates (e.g. 200 Hz ACC vs 1 Hz HR). - High-Frequency Recording: To record data at the maximum native rate (e.g. capturing all 200 Hz accelerometer samples or all 130 Hz ECG samples), you should write samples to the CSV directly within the device callback functions (such as
acc_callback_h10orppg_callback_sense) in the scripts. To prevent rate mismatch conflicts, it is recommended to write to separate stream-specific files (e.g.,*_acc.csv,*_ppg.csv).
โจ Key Features
- Multi-Device Support: Captures raw physiological telemetry from the Polar H10 chest strap, Polar Verity Sense optical sensor, and Polar smartwatch line (Grit, Vantage).
- High-Frequency Waveforms: Live streaming and rendering of ECG electrical signals (130Hz), PPG optical pulse waves (55Hz), and IMU kinematics (3-axis Accelerometer, Gyroscope, and Magnetometer).
- Stress & HRV Analysis: Dynamic calculation of RMSSD from R-R intervals (heart rate variability) and optical PPI data feed.
- Console Terminal Dashboard: Full-featured interactive terminal view with a heart rate trend sparkline graph, background battery status checking, active stream rate monitor, and live event marker logs.
- Automated Logging: Saves session data periodically at 1 Hz directly to CSV files inside the
data/directory.
๐ Project Structure
Polar-Python-SDK/
โโโ setup.ps1 # PowerShell automatic environment setup
โโโ start.ps1 # PowerShell application launcher
โโโ src/polar_ble_sdk/
โ โโโ app_streamlit.py # Main Streamlit Dashboard (tabbed waveforms & kinematics)
โ โโโ connector/ # BLE Device connection and data streaming layer
โ โ โโโ stream/ # Specialized device modules (Base, H10, VeritySense, Watch)
โ โโโ dashboard_utils.py # Shared helpers (RMSSD, sparkline, battery, CSV logging)
โ โโโ reader/ # Real-time data reading and ML stress inference logic
โ โโโ ml/ # Machine learning package (sample_data, train_model)
โโโ scripts/ # Consolidated CLI Tools
โ โโโ monitor_polar_terminal.py # Premium live console dashboard with logging & hotkeys
โ โโโ connect_polar.py # Simple streaming utility
โ โโโ download_datasets.py # Dataset setup helper
โ โโโ replicate_tabnet_stress.py # TabNet model training pipeline
โ โโโ scan_ble.py # BLE device discovery scanner
โ โโโ pair_watch.ps1 # Windows WinRT device pairing script
โ โโโ ... # Helper and setup utilities
โโโ tests/ # 83 verified unit tests (pytest)
โโโ data/ # Session log files and datasets
โโโ models/ # Pickled ML models and scalers
โโโ docs/ # Project guides
๐งช Testing & Code Quality
The codebase includes comprehensive unit testing and static type checking.
# Run the complete unit test suite
pytest tests/ -v --cov=.
# Run static type analysis checks
mypy src/ scripts/
๐ License & Credits
See the LICENSE file for details.
Built for Python 3.8+ natively on Windows 10/11 environments.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polar_ble_sdk-0.1.1.tar.gz.
File metadata
- Download URL: polar_ble_sdk-0.1.1.tar.gz
- Upload date:
- Size: 50.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f66e6e0db1d57a80cce0b33d7669c1bed3caa8ce3931fd49a753473e6fe20e6
|
|
| MD5 |
3e33ce6c352bbc00ee6519da731a27cd
|
|
| BLAKE2b-256 |
55751d36c73b52085f662ede3787b8fda952c76c6161e9fc4e21bf8a84938ff8
|
Provenance
The following attestation bundles were made for polar_ble_sdk-0.1.1.tar.gz:
Publisher:
publish.yml on PhelaPoscam/Polar-Python-SDK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polar_ble_sdk-0.1.1.tar.gz -
Subject digest:
6f66e6e0db1d57a80cce0b33d7669c1bed3caa8ce3931fd49a753473e6fe20e6 - Sigstore transparency entry: 1935645728
- Sigstore integration time:
-
Permalink:
PhelaPoscam/Polar-Python-SDK@d8dfef5bf4b52219880691fc761c9d967bb26cb8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/PhelaPoscam
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d8dfef5bf4b52219880691fc761c9d967bb26cb8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file polar_ble_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: polar_ble_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 47.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4e33b34d48a4bc3979dd9b828e27a92e33617a018342ed0e6c12c12c1cbb61c
|
|
| MD5 |
e2b9dd538f6fff4359970b09ba9c2346
|
|
| BLAKE2b-256 |
7a92d6b815658aca916bb1897e5588f4ab4116409e18bd20a5ddb531de0816a3
|
Provenance
The following attestation bundles were made for polar_ble_sdk-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on PhelaPoscam/Polar-Python-SDK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polar_ble_sdk-0.1.1-py3-none-any.whl -
Subject digest:
e4e33b34d48a4bc3979dd9b828e27a92e33617a018342ed0e6c12c12c1cbb61c - Sigstore transparency entry: 1935645759
- Sigstore integration time:
-
Permalink:
PhelaPoscam/Polar-Python-SDK@d8dfef5bf4b52219880691fc761c9d967bb26cb8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/PhelaPoscam
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d8dfef5bf4b52219880691fc761c9d967bb26cb8 -
Trigger Event:
release
-
Statement type: