Skip to main content

SpO2 Watch Python SDK

The adi-spo2-watch provides an object-oriented interface for interacting with ADI's VSM Study Watch 4.5 platform (SpO2 Watch).

Installation

pip install adi-spo2-watch

Description

A user application can use the SDK to receive complete packets of bytes over a physical interface (USB or BLE) and decode it. The functionality is organized into applications, some of which own sensors, some own system-level functionality (i.e. file system), and while others own algorithms. The hierarchy of objects within the SDK mirrors the applications present on the device. Each application has its own object within the SDK hierarchy, which is used to interact with that application. A brief guide on using the SDK and few examples have been added below.

Firmware Setup

https://github.com/analogdevicesinc/spo2-watch-sdk/blob/main/firmware/Firmware_update_guide.pdf

Getting started with SDK

Import the adi-spo2-watch module into your application code

from adi_spo2_watch import SDK

Instantiate the SDK object by passing the com port number

sdk = SDK('COM28')

The application objects can be instantiated from the sdk object. In order to instantiate an application object, we'll have to pass a call-back function as an input argument which can be used to retrieve the data from the application object. Define a callback function as displayed below.

def callback_data(data):
    print(data)

Once the call-back function is defined, you can instantiate the application object as shown below.

application = sdk.get_sensorhub_application()
application.set_callback(callback_data, stream=application.SH_ADXL_STREAM)

Each application object has various methods that can be called by referring to the application. Almost all method in an application returns result in a dict.

Basic Example:

import time
from datetime import datetime
from adi_spo2_watch import SDK

# Callback function to receive adxl data
def callback_data(data):
    sequence_number = data["payload"]["sequence_number"]
    for stream_data in data["payload"]["stream_data"]:
        dt_object = datetime.fromtimestamp(stream_data['timestamp'] / 1000)  # convert timestamp from ms to sec.
        print(f"seq :{sequence_number} timestamp: {dt_object} x,y,z :: ({stream_data['x']}, "
                f"{stream_data['y']}, {stream_data['z']})")


if __name__ == "__main__":
    sdk = SDK("COM4")
    application = sdk.get_sensorhub_application()

    # Quickstart adxl stream
    application.set_callback(callback_data, stream=application.SH_ADXL_STREAM)
    application.enable_csv_logging("adxl.csv", stream=application.SH_ADXL_STREAM) # Logging adxl data to csv file
    application.subscribe_stream(stream=application.SH_ADXL_STREAM)
    application.set_operation_mode(application.SH_CONFIG_ADXL_MODE)
    application.start_sensor()
    time.sleep(10)
    application.stop_sensor()
    application.unsubscribe_stream(stream=application.SH_ADXL_STREAM)
    application.disable_csv_logging(stream=application.SH_ADXL_STREAM)

Permission Issue in Ubuntu

1 - You can run your script with admin (sudo).

2 - If you don't want to run scripts as admin follows the steps below:

  • add user to tty and dialout group
sudo usermod -aG tty <user>
sudo usermod -aG dialout <user>
  • create a file at /etc/udev/rules.d/ with name 10-adi-usb.rules:
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0456", ATTRS{idProduct}=="2cfe", MODE="0666", GROUP="dialout"
  • reboot

All streams packet structure : https://analogdevicesinc.github.io/spo2-watch-sdk/python/_rst/adi_spo2_watch.core.packets.html#module-adi_spo2_watch.core.packets.stream_data_packets

Documentation : https://analogdevicesinc.github.io/spo2-watch-sdk/python

Examples : https://github.com/analogdevicesinc/spo2-watch-sdk/tree/main/python/samples

License : https://github.com/analogdevicesinc/spo2-watch-sdk/blob/main/LICENSE

Changelog https://github.com/analogdevicesinc/spo2-watch-sdk/blob/main/python/CHANGELOG.md

Metadata

Release files for adi-spo2-watch 6.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adi-spo2-watch 6.10.0
File Size Uploaded
adi_spo2_watch-6.10.0.tar.gz 115.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for adi-spo2-watch 6.10.0
File Interpreter ABI Platform
adi_spo2_watch-6.10.0-py3-none-any.whl Python 3 none any Details

Total release size: 307.5 kB

Release files / adi_spo2_watch-6.10.0.tar.gz

Download URL adi_spo2_watch-6.10.0.tar.gz
Size 115.6 kB
Tags Source
SHA-256 checksum
How to use checksums
11767ac4f872d45f7d5f31889576b3799acf6c5f88e379819ddede1a0d1df0bb
BLAKE2b-256 checksum
How to use checksums
1750bc5fc590d0cd8514376bab7f7038c4e24e37a7b4c1458c6d7688cce9f85d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / adi_spo2_watch-6.10.0-py3-none-any.whl

Download URL adi_spo2_watch-6.10.0-py3-none-any.whl
Size 191.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31f281f112a124c4889e416726334acc2bc01db7cabe932c31c0772064f2c0b0
BLAKE2b-256 checksum
How to use checksums
88b7c58c077be1a4a6c077a677e39dd32ca8d49a540d3f8b237ae123e1743406
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

6.10.0 This release

2 release files

6.6.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page