polarpy
Tools for reading and fusing live data streams from Polar OH1 (PPG) and H10 (ECG) sensors.
Requirements
If installing from the repo you need pygatttool (pip install pygatttool).
Installation
pip install polarpy
Usage
The following code starts the raw PPG and IMU streams on a Polar OH1, fuses the blocks pf data in the two streams at 135Hz, and provides a single output stream, each record having a timestamp, the PPG signal values for each of the 3 pairs of LEDs, and the corresponding accerelometer x, y and z readings.
from polarpy import OH1
OH1_ADDR = "A0:9E:1A:7D:3C:5D"
OH1_CONTROL_ATTRIBUTE_HANDLE = 0x003f
OH1_DATA_ATTRIBUTE_HANDLE = 0x0042
def callback(type: str, timestamp: float, payload: dict):
print(f'{timestamp} {payload}')
if '__main__' == __name__:
device = OH1(address=OH1_ADDR,
control_handle=OH1_CONTROL_ATTRIBUTE_HANDLE,
data_handle=OH1_DATA_ATTRIBUTE_HANDLE,
callback=callback)
if device.start():
while device.run():
pass
The output looks something like this:
3.94 {'ppg0': 263249, 'ppg1': 351764, 'ppg2': 351928, 'ax': 0.775, 'ay': -0.42, 'az': 0.476}
3.947 {'ppg0': 263297, 'ppg1': 351964, 'ppg2': 352077, 'ax': 0.775, 'ay': -0.42, 'az': 0.476}
3.954 {'ppg0': 263319, 'ppg1': 352062, 'ppg2': 352013, 'ax': 0.778, 'ay': -0.417, 'az': 0.481}
3.962 {'ppg0': 263293, 'ppg1': 352106, 'ppg2': 352082, 'ax': 0.778, 'ay': -0.417, 'az': 0.481}
3.969 {'ppg0': 263440, 'ppg1': 352273, 'ppg2': 352199, 'ax': 0.778, 'ay': -0.417, 'az': 0.481}
...
The callback is used (rather than returning data from run()) because the blocks of PPG, ECG and IMU data arrive with different lengths and at different speeds. The individual samples from each channel must be buffered and interleaved, timestamps interpolated, then delivered asynchronously through the callback.
The address and attribute handles for your particular device can be found using gatttool or another BLE tool such as nRF Connect.
Metadata
Release files for polarpy 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| polarpy-0.1.1.tar.gz | 7.6 kB | Without provenance | Details for polarpy-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| polarpy-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for polarpy-0.1.1-py3-none-any.whl |
Total release size: 17.7 kB
Release files / polarpy-0.1.1.tar.gz
| Download URL | polarpy-0.1.1.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78d3112db23fee95d965931815b4f2d6bcc3359d400a50b78e00249504efc15a
|
|
BLAKE2b-256 checksum How to use checksums |
da18c0a144e12f591ff08f905d2e5a41c52499af892b9c57d21f0da9476b0d6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.8.10 Linux/5.4.0-144-generic
|
Release files / polarpy-0.1.1-py3-none-any.whl
| Download URL | polarpy-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e436dfc5edb2305c9fe48c0bdbf7d83e94146b1cd9d4f2a024817f9f2d59cfae
|
|
BLAKE2b-256 checksum How to use checksums |
cf0fed67a8d1ad16449903d528cb52677c8c10305728163915c6f00134635560
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.8.10 Linux/5.4.0-144-generic
|
Security for polarpy 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.