Skip to main content

Study Watch Python SDK

The adi-study-watch provides an object-oriented interface for interacting with ADI's VSM study watch platform.

Installation

pip install adi-study-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/study-watch-sdk/blob/main/firmware/Study_Watch_Firmware_Upgrade.pdf

Getting started with SDK

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

from adi_study_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 adxl_cb(data):
    print(data)

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

adxl_app = sdk.get_adxl_application()
adxl_app.set_callback(adxl_cb)

Each application object has various methods that can be called by referring to the application. An example of retrieving the sensor status is shown below. Almost all method in an application returns result in a dict.

packet = adxl_app.get_sensor_status() # returns dict
print(packet)

Basic Example:

import time
from datetime import datetime
from adi_study_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_adxl_application()
    application.set_callback(callback_data)

    # quickstart adxl stream
    application.start_sensor()
    application.enable_csv_logging("adxl.csv") # logging adxl data to csv file
    application.subscribe_stream()
    time.sleep(10)
    application.unsubscribe_stream()
    application.disable_csv_logging()
    application.stop_sensor()

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/study-watch-sdk/python/_rst/adi_study_watch.core.packets.html#module-adi_study_watch.core.packets.stream_data_packets

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

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

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

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adi_study_watch-5.17.tar.gz (115.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

adi_study_watch-5.17.0-py3-none-any.whl (204.1 kB view details)

Uploaded Python 3

adi_study_watch-5.17-py3-none-any.whl (204.0 kB view details)

Uploaded Python 3

File details

Details for the file adi_study_watch-5.17.tar.gz.

File metadata

  • Download URL: adi_study_watch-5.17.tar.gz
  • Upload date:
  • Size: 115.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for adi_study_watch-5.17.tar.gz
Algorithm Hash digest
SHA256 5e505353d30ab117c1b46a8843826e621f5039f8b419274a8631114511439177
MD5 e237b8dd0cf947c3134777e925bcb5b7
BLAKE2b-256 8a1b5b33cdba0c0493290ebfa391568686dbae4cde04db5e51958559b844bf56

See more details on using hashes here.

File details

Details for the file adi_study_watch-5.17.0-py3-none-any.whl.

File metadata

File hashes

Hashes for adi_study_watch-5.17.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5819c578705f605f9cb359dc7b25271b8dddeecef5a2fc0118f1654cdfb9d2e
MD5 a688f143b8c7e2874e9da6c7d87b4f51
BLAKE2b-256 5c6203baa45b4f3d2b02014708922d57e6db6f2146fd3a30c1d3d5119d487520

See more details on using hashes here.

File details

Details for the file adi_study_watch-5.17-py3-none-any.whl.

File metadata

  • Download URL: adi_study_watch-5.17-py3-none-any.whl
  • Upload date:
  • Size: 204.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for adi_study_watch-5.17-py3-none-any.whl
Algorithm Hash digest
SHA256 bcd2f2d8d501d7401f8d521677876359f953ec020d3c10c7e8a9dcb5fd264029
MD5 5444da5cf42a82c578a2bae24baac74d
BLAKE2b-256 de21be02b38b1d4af26fc4d795afa8d4fcbcfdf5b61527830f6d2b90387964b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page