TeslasuitDocumentation
APIs

Measure HRV

Python 3.8+ · Teslasuit v4.5.6+ (XR5 recommended) · SDK 2.5.1+

Read heart rate variability (HRV) from the Teslasuit PPG sensor: start raw streaming and print the Mean inter-beat interval as each reading arrives.

Code for HRV data#

from teslasuit_sdk import ts_api
import teslasuit_sdk.subsystems.ts_ppg


def main():
    # Initialize the API and wait for a device to connect
    api = ts_api.TsApi()
    device = api.get_device_manager().get_or_wait_last_device_attached()

    # Start raw PPG streaming
    ppg = device.ppg
    ppg.start_raw_streaming()

    # Read Mean inter-beat interval — blocks until HRV data is ready
    while True:
        hrv_data = ppg.get_hrv_data_on_ready()
        print("Mean inter-beat interval:", hrv_data.mean_rr)


if __name__ == "__main__":
    main()

Expected output#

Device connected: a1b2c3d4-e5f6-7890-abcd-ef1234567890
Mean inter-beat interval: 750
Mean inter-beat interval: 748
...

Safety. For valid HRV/PPG readings, wait at least 30 seconds after starting the PPG stream and make sure the PPG subsystem is calibrated.


Explore these references and guides to build on this example and get the most out of Teslasuit PPG features:

Essential API references#

Practical guides & examples#

Deeper dives & broader concepts#

  • PPG Main Concept: The conceptual background behind the photoplethysmography subsystem.
  • Teslasuit Main Concepts: Fundamental articles explaining Teslasuit technology and how PPG fits within the larger suite of subsystems.