Read heart rate
Python 3.8+ · Teslasuit v4.5.6+ (XR5 recommended) · SDK 2.5.1+
Read live heart rate from a Teslasuit photoplethysmography (PPG) node: start raw streaming and print the heart rate as each reading arrives.
Code for heart rate 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 heart rate — blocks until PPG data is ready
while True:
node_data = ppg.get_data()
# nodes[0] — XR5 has one PPG sensor node; index 0 is always the suit
print("Heart Rate:", node_data.nodes[0].heart_rate)
if __name__ == "__main__":
main()Expected output#
Device connected: a1b2c3d4-e5f6-7890-abcd-ef1234567890
Heart Rate: 72
Heart Rate: 74
...What to read next#
Explore these references and guides to build on this example and get the most out of Teslasuit PPG features:
Essential API references#
- PPG Subsystem API Reference: Full reference for the
TsPpgclass used in this example. - Core Data Structures — PPG: Reference for the raw, HRV, and heart-rate data types.
Practical guides & examples#
- Measure HRV: The companion PPG example for reading heart rate variability.
- Examples Overview: Browse the full set of runnable 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.
