Aidlab SDK for Python allows you to read data from many Aidlabs at once. This SDK supports Windows, macOS, and Linux operating systems and has been tested using Python 3.

Aidlab SDK does not support Anaconda.


Note that laptop or PC with Bluetooth 4.0+ module is required.


Working with Aidlab using Python allows you to juggle with data almost immediately. This example shows how to receive data from nearby discovered Aidlabs:

import Aidlab

class MainManager(Aidlab.Aidlab):

    def did_connect(self, aidlab):
        print("Connected to: ", aidlab.address)

    def did_disconnect(self, aidlab):
        print("Disconnected from: ", aidlab.address)

    def did_receive_respiration(self, aidlab, timestamp, values):

if __name__ == '__main__':

    signals = ["respiration"]

    main_manager = MainManager()

    while True:

Save it as, turn the Aidlab on and run:


Note: run with the sudo on Unix-based systems.


The Aidlab class exposes the connect function which allows you to scan nearby Aidlabs and listen to data distribution events:

connect(signals: [str], addresses: [str])

The connect function expects two parameters:

  • signals - an array of signals you would like to listen to. List of the available signals.
  • addresses - an optional parameter which you can use if you know the address(es) of the Aidlab(s) you'd like to connect to.

Python SDK allows you to connect to several Aidlabs at the same time, however, simultaneous subscription to ecg and respiration signals due to the high sampling rate may cause delay or loss of samples on older Bluetooth LE chips.

Since both the Bluetooth detection and name lookup process are probabilistic, connect will sometimes fail to detect devices that are in range. In these cases, it may be a good idea to try again once or twice before giving up.

Since we are inheriting from Aidlab, we can now listen to events.

For each event, an IAidlab object is a parameter. You can obtain the following information from it:

  • firmware_revision - the firmware version currently installed on your Aidlab
  • serial_number - Aidlab's serial number
  • hardware_revision - Aidlab's hardware version
  • address - Aidlab's MAC address

You can also use several functions:

    # modify the ECG filtration method (you can choose between normal and aggressive)
    def set_ecg_filtration_method(self, method):

    # start data synchronization
    def start_synchronization(self):

    # stop data synchronization
    def stop_synchronization(self):

    # send commands to Aidlab (e.g. to change LED brightness)
    def send(self, command):

Commands can not be sent to Aidlab while synchronization is enabled. If you're utilizing synchronization in your app, remember to always use the stop_synchronization function before using send.

Bluetooth address

Aidlab SDK represents Aidlab's Bluetooth address as a string of the form xx:xx:xx:xx:xx, where each x is a hexadecimal character representing one octet of the 48-bit address, with most significant octets listed first. Bluetooth devices on Linux and Windows will always be identified using an address string of this form. For example: b9:b2:76:d7:ac:16.

On Mac, the Aidlab's Bluetooth address is represented as a UUID, in such form: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, as 32 hexadecimal (base-16) digits, displayed in 5 groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and 4 hyphens). For example: 64cc003b-96f3-46f5-bc1e-d846e4555e79.

If you don't know the Aidlab's Bluetooth address, see "Finding the Bluetooth address" under the FAQ section below.

Connecting to two (or more) Aidlabs

This section will show how to stream respiration and battery from two Aidlabs simultaneously:

1. Turn the Aidlabs on.

2. Run the connectivity routine:

import Aidlab

first_address = "<YOUR FIRST AIDLAB's ADDRESS>"
second_address = "<YOUR SECOND AIDLAB's ADDRESS>"

class MainManager(Aidlab.Aidlab):

    def is_connected(self, aidlab):
        print("Connected to: ", aidlab.address)

    def is_disconnected(self, aidlab):
        print("Disconnected from: ", aidlab.address)

    def did_receive_respiration(self, aidlab, timestamp, values):
        if aidlab_address == first_address:
            print("Respiration: ", values, aidlab.address)
        elif aidlab_address == second_address:
            print("Respiration: ", values, aidlab.address)

    def did_receive_battery_level(self, aidlab, stateOfCharge):
        if aidlab_address == first_address:
            print("Battery: ", stateOfCharge, aidlab.address)
        elif aidlab_address == second_address:
            print("Battery: ", stateOfCharge, aidlab.address)

if __name__ == '__main__':

    signals = ["battery", "respiration"]

    main_manager = MainManager()

    while True:

3. Wait till connection will be established.

Finding the Bluetooth address

In order to connect to Aidlabs of your choice, the Bluetooth address must be known.

Obtaining Aidlab's MAC Bluetooth address (Linux)

You scan Aidlab address with a BLE scanner. For instance, on Linux you can use hcitool lescan:

$ sudo hcitool lescan
LE Scan ...
b9:b2:76:d7:ac:16 (aidlab)

Alternatively, you can get a list of all available Bluetooth devices and their MAC addresses using the command hciconfig, like so:

$ hciconfig
hci0:   Type: BR/EDR  Bus: USB
        BD Address: b9:b2:76:d7:ac:16  ACL MTU: 1017:8  SC0 MTU: 64:8

To test the connectivity, you can use the gatttool:

gatttool -b b9:b2:76:d7:ac:16 -I
char-write-cmd 12 0100


You can take control over synchronization of the data from your Aidlab's internal memory to your app using IAidlab functions mentioned above and special synchronization-related events. A simple example illustrating data synchronization is available in the file. The full list of events can be found under Synchronization events here.

Aidlab sends past data and currently recorded data to your app simultaneously.

To be able to synchronize data, you have to enable it first. For more information, go to Enabling data synchronization on the Getting Started page.

SDK State

If you want to get information about the current state of the SDK, add the following lines to your code:

import logging


results matching ""

    No results matching ""