Getting Started

Aidlab SDK lets applications interact with Aidlab. It works well with Python, Android, and iOS and can be easily implemented in applications created natively or in Unity. To use it, you have to download Aidlab SDK and include it in your project.

The most recent version of the Aidlab SDK can be found here.

To see installation guide and code examples for your specific platform, jump to one of the following sections: Unity, Android, iOS or Python.

Reading signals

With the use of the Aidlab SDK you can retrieve several signals from it, like respiration rate or skin temperature. Depending on the language of your choice, obtaining signals can be as simple as:

Python
Kotlin
Unity
Swift
aidlab.connect(["respiration", "temperature"])
val signals = arrayOf(Signal.ecg, Signal.respiration);
aidlab.connect(signals)
Signal[] signals = { Signal.respiration, Signal.temperature };
aidlab.connect(signals);
aidlab.connect([.respiration, .temperature])

You can ask Aidlab for signals listed below:

Signal description Signal name First introduced
Connectivity status. Note that there is no associated signal name, as one can obtain this information anytime. n/a Firmware 1.0.0
Raw readings from the ECG sensor. Each sample is represented in volts. ecg Firmware 1.0.0
Raw readings from the respiration sensor including respiration rate. This signal provides enough data to display a graph representing the breathing pattern. Each raw sample is in volts. respiration Firmware 1.0.0
Battery level. Enabling battery monitoring will notify about Aidlab's state of charge. Value can be between 0.0 (discharged) and 100.0 (fully charged). battery Firmware 1.0.0
Current activity. You can request updates when the current type of activity changes. Aidlab can detect still, walking, running, automotive, and cycling. activity Firmware 2.1.0
Total steps. Steps are accumulated since Aidlab's startup. steps Firmware 2.1.0
Orientation. Within this signal, two events are available with the following sets of values: RPY angles (roll, pitch, yaw) and the quaternions (qw, qx, qy, qz) of the user's orientation. Together with the motion signal, it also enables the bodyweight workout classifier that can detect burpees, jumps, push-ups, and sit-ups. orientation Firmware 2.2.6
Heart rate and HRV. Heart rate is a total number of user's heartbeats, calculated from a 1-minute window. HRV is an array of the last 9 beat-to-beat events, derived from the ECG signal. HRV values are represented as a time difference (in milliseconds) between each heartbeat. heartRate Firmware 2.2.0+
Skin temperature. This signal will read skin temperature from the infrared skin temperature sensor. Don't confuse skin temperature with body temperature. temperature Firmware 1.0.0
Readings from the 9-axis motion sensor unit. Within this signal, three events are available with the following sets of values: acceleration (ax, ay, az), angular velocity (gx, gy, gz) and magnetic induction (mx, my, mz). Together with the orientation signal, it also enables the bodyweight workout classifier that can detect burpees, jumps, push-ups, and sit-ups. motion Firmware 2.2.6
Status if Aidlab is placed properly on user's chest. You can use that information to make decisions when to start processing data or display a short user guide on how to wear Aidlab in your app. This information can be obtained only if heartRate signal is enabled. n/a Firmware 1.0.0
Sound volume readings from the microphone. The highest possible value is 65536 (very loud), and the lowest is 0 (vacuum). Note, that due to the limited computing power of Aidlab, it’s not possible to acquire data from the microphone and motion sensor at the same time. That means that even if you subscribe to both the soundVolume and motion signals, you’ll only get back one kind of data. soundVolume Firmware 2.2.5

From now on, Aidlab will send data to your application at the sample rate depending on the signal.

Events

Python
Kotlin
Unity
Swift
    def did_connect(self, aidlab):
        pass

    def did_disconnect(self, aidlab):
        pass

    def did_receive_ecg(self, aidlab, timestamp, values):
        """Called when a new ECG samples was received.
        """
        pass

    def did_receive_respiration(self, aidlab, timestamp, values):
        """Called when a new respiration samples was received.
        """
        pass

    def did_receive_respiration_rate(self, aidlab, timestamp, value):
        """Called when a new respiration sample was received.
        """
        pass

    def did_receive_battery_level(self, aidlab, state_of_charge):
        """If battery monitoring is enabled, this event will notify about Aidlab's
           state of charge. You never want Aidlab to run low on battery, as it can
           lead to it's sudden turn off. Use this event to inform your users about
           Aidlab's low energy.
        """
        pass

    def did_receive_skin_temperature(self, aidlab, timestamp, value):
        """Called when a skin temperature was received.
        """
        pass

    def did_receive_accelerometer(self, aidlab, timestamp, ax, ay, az):
        """Called when new accelerometer data were received.
        """
        pass

    def did_receive_gyroscope(self, aidlab, timestamp, gx, gy, gz):
        """Called when new gyroscope data were received.
        """
        pass

    def did_receive_magnetometer(self, aidlab, timestamp, mx, my, mz):
        """Called when new magnetometer data were received.
        """
        pass

    def did_receive_orientation(self, aidlab, timestamp, roll, pitch, yaw):
        """Called when received orientation, represented in RPY angles.
        """
        pass

    def did_receive_quaternion(self, aidlab, timestamp, qw, qx, qy, qz):
        """Called when new quaternion data were received.
        """
        pass

    def did_receive_activity(self, aidlab, timestamp, activity):
        """Called when activity data were received.
        """
        pass

    def did_receive_steps(self, aidlab, timestamp, steps):
        """Called when total steps did change.
        """
        pass

    def did_receive_heart_rate(self, aidlab, timestamp, hrv, heartRate):
        """Called when a heart rate did change.
        """
        pass

    def wear_state_did_change(self, aidlab, state):
        """Called when a significant change of wear state did occur. You can use
           that information to make decisions when to start processing data, or
           display short user guide on how to wear Aidlab in your app.
        """
        pass

    def did_receive_sound_volume(self, aidlab, timestamp, sound_volume):
        pass

    def did_detect_exercise(self, aidlab, exercise):
        pass

    def did_receive_command(self, aidlab):
        pass
interface AidlabDelegate {

    /**
     * Called after establishing connection with the device
     */
    fun didConnectAidlab(aidlab: IAidlab)

    /**
     * Called after the connection was closed
     */
    fun didDisconnectAidlab(aidlab: IAidlab)

    /**
     * Called when a new ECG samples was received.
     * @param  values     New ECG samples
     */
    fun didReceiveECG(aidlab: IAidlab, timestamp: Long, values: FloatArray)

    /**
     * Called when a new respiration samples was received.
     * @param  values     The new samples
     */
    fun didReceiveRespiration(aidlab: IAidlab, timestamp: Long, values: FloatArray)

    /**
     * Called when an new respiration rate was received.
     * @param value new respiration rate value
     */
    fun didReceiveRespirationRate(aidlab: IAidlab, timestamp: Long, value: Int)

    /**
     * Called when a new state of charge was received.
     * @param  stateOfCharge    Battery level in % (0 - 100)
     */
    fun didReceiveBatteryLevel(aidlab: IAidlab, stateOfCharge: Int)

    /**
     * Called when skin temperature was received.
     * @param  value    Skin temperature in °C
     */
    fun didReceiveSkinTemperature(aidlab: IAidlab, timestamp: Long, value: Float)

    fun didReceiveAccelerometer(aidlab: IAidlab, timestamp: Long, ax: Float, ay: Float, az: Float)

    fun didReceiveGyroscope(aidlab: IAidlab, timestamp: Long, qx: Float, qy: Float, qz: Float)

    fun didReceiveMagnetometer(aidlab: IAidlab, timestamp: Long, mx: Float, my: Float, mz: Float)

    fun didReceiveQuaternion(aidlab: IAidlab, timestamp: Long, qw: Float, qx: Float, qy: Float, qz: Float)

    /**
     * Called when received RPY angles.
     * @param roll
     * @param pitch
     * @param yaw
     */
    fun didReceiveOrientation(aidlab: IAidlab, timestamp: Long, roll: Float, pitch: Float, yaw: Float)

    /**
     * Called when an new activity type was detected
     * @param activity  new activity type
     */
    fun didReceiveActivity(aidlab: IAidlab, timestamp: Long, activity: ActivityType)

    /**
     * Called when the number of total steps did change.
     * @param steps The total number of steps the user has taken with Aidlab.
     */
    fun didReceiveSteps(aidlab: IAidlab, timestamp: Long, value: Long)

    /**
     * Called when an new heart rate sample was received from the device
     * @param hrv  array of times between the peaks of the heart in ms
     * @param hearRate  new heart rate value
     */
    fun didReceiveHeartRate(aidlab: IAidlab, timestamp: Long, hrv: IntArray, heartRate: Int)

    /**
     * Called when a significant change of wear state did occur. You can use
     * that information to make decisions when to start processing data, or
     * display short user guide how to wear Aidlab in your app.
     * @param  wearState    Current wear state
     */
    fun wearStateDidChange(aidlab: IAidlab, wearState: WearState)

    fun didDetectExercise(aidlab: IAidlab, exercise: Exercise)

    fun didReceiveSoundVolume(aidlab: IAidlab, timestamp: Long, value: Int)

    fun didReceiveCommand(aidlab: IAidlab)

    fun didReceiveError(error: String)

}
public interface AidlabDelegate {

    void didConnectAidlab(IAidlab aidlab);

    void didDisconnectAidlab(IAidlab aidlab);

    /**
     * Called when a new ECG samples was received.
     * @param  values     The new sample
     */
    void didReceiveECG(IAidlab aidlab, Int64 timestamp, float[] values);

    /**
     * Called when a new respiration samples was received.
     * @param  values     The new samples
     */
    void didReceiveRespiration(IAidlab aidlab, Int64 timestamp, float[] values);

    /**
     * Called when a new respiration rate was received.
     * @param value New respiration rate.
     */
    void didReceiveRespirationRate(IAidlab aidlab, Int64 timestamp, int value);

    /**
     * If battery monitoring is enabled, this event will notify about Aidlab's
     * state of charge. You never want Aidlab to run low on battery, as it can
     * lead to its sudden turn off. Use this event to inform your users about
     * Aidlab's low energy.
     * @param stateOfCharge    Battery level in % (0.0 - 100.0).
     */
    void didReceiveBatteryLevel(IAidlab aidlab, int stateOfCharge);
    
    /**
     * Called when a skin temperature was received.
     * @param value    Skin temperature in °C
     */
    void didReceiveSkinTemperature(IAidlab aidlab, Int64 timestamp, float value);
    
    void didReceiveAccelerometer(IAidlab aidlab, Int64 timestamp, float ax, float ay, float az);
    
    void didReceiveGyroscope(IAidlab aidlab, Int64 timestamp, float qx, float qy, float qz);
    
    void didReceiveMagnetometer(IAidlab aidlab, Int64 timestamp, float mx, float my, float mz);
    
    void didReceiveQuaternion(IAidlab aidlab, Int64 timestamp, float qw, float qx, float qy, float qz);
    
    /**
     * Called when received orientation, represented in RPY angles.
     * @param roll
     * @param pitch
     * @param yaw
     */
    void didReceiveOrientation(IAidlab aidlab, Int64 timestamp, float roll, float pitch, float yaw);
    
    /**
     * Called when a new activity type was detected.
     * @param activity  new activity type
     */
    void didReceiveActivity(IAidlab aidlab, Int64 timestamp, ActivityType activity);
    
    /**
     * Called when the number of total steps did change.
     * @param steps The total number of steps the user has taken with Aidlab.
     */
    void didReceiveSteps(IAidlab aidlab, Int64 timestamp, int steps);
    
    /**
     * Called when heart rate did change.
     * @param hrv  array of times between the peaks of the heart in ms
     * @param hearRate  new heart rate value
     */
    void didReceiveHeartRate(IAidlab aidlab, Int64 timestamp, int[] hrv, int heartRate);
    
    /**
     * Called when a significant change of wear state did occur.
     * @param  wearState    Current wear state.
     */
    void wearStateDidChange(IAidlab aidlab, WearState wearState);
    
    void didDetectExercise(IAidlab aidlab, Exercise exercise);
}
public protocol AidlabDelegate: class {

    func didReceiveECG(_ aidlab: IAidlab, timestamp: UInt64, values: [Float])

    func didReceiveRespiration(_ aidlab: IAidlab, timestamp: UInt64, values: [Float])

    func didReceiveBatteryLevel(_ aidlab: IAidlab, stateOfCharge: UInt8)

    func didReceiveSteps(_ aidlab: IAidlab, timestamp: UInt64, value: UInt64)

    func didReceiveSkinTemperature(_ aidlab: IAidlab, timestamp: UInt64, value: Float)

    func didReceiveAccelerometer(_ aidlab: IAidlab, timestamp: UInt64, ax: Float, ay: Float, az: Float)
    
    func didReceiveGyroscope(_ aidlab: IAidlab, timestamp: UInt64, qx: Float, qy: Float, qz: Float)
    
    func didReceiveMagnetometer(_ aidlab: IAidlab, timestamp: UInt64, mx: Float, my: Float, mz: Float)
    
    func didReceiveQuaternion(_ aidlab: IAidlab, timestamp: UInt64, qw: Float, qx: Float, qy: Float, qz: Float)

    func didReceiveOrientation(_ aidlab: IAidlab, timestamp: UInt64, roll: Float, pitch: Float, yaw: Float)

    func didReceiveHeartRate(_ aidlab: IAidlab, timestamp: UInt64, hrv: [Int32], heartRate: Int32)

    func didReceiveRespirationRate(_ aidlab: IAidlab, timestamp: UInt64, value: UInt32)

    func didReceiveSoundVolume(_ aidlab: IAidlab, timestamp: UInt64, soundVolume: UInt16)

    func didDetect(_ aidlab: IAidlab, exercise: Exercise)

    func didDetect(_ aidlab: IAidlab, timestamp: UInt64, activity: ActivityType)

    func didDisconnect(_ aidlab: IAidlab)

    func didConnect(_ aidlab: IAidlab)

    func didReceiveError(_ aidlab: IAidlab, error: Error)

    func didReceiveRSSI(_ aidlab: IAidlab, rssi: Int32)
    /**
    * Called when a significant change of wear state did occur. You can use
    * that information to make decisions when to start processing data, or
    * display short user guide how to wear Aidlab in your app.
    * @param  wearState    Current wear state.
    */
    func wearStateDidChange(_ aidlab: IAidlab, state: WearState)
    
    func didReceiveCommand(_ aidlab: IAidlab)
}

Enabling data synchronization

If you're using our official Android or iOS app, Aidlab saves data (including ECG, activity, steps, HR, respiration and skin temperature) to its flash storage by default. If you'd like to change the saved signals to fit your own app, enter the Aidlab debug shell:

  1. Enter chrome://flags/#enable-experimental-web-platform-features in your Chrome browser.
  2. Enable the highlighted flag.
  3. Restart Chrome.
  4. Visit debug console.
  5. Turn Aidlab on, so the pulsating green diode will indicate the pending connection.
  6. Type connect and press enter.
  7. Select Aidlab from the list.
  8. Wait till command prompt will be visible,

and use the following command with the name of your chosen signal (for example ecg):

> sync enable ecg

From now on, if your Aidlab is switched on and placed properly on user's chest, but not connected to any device, it will save ecg to its flash memory. To subscribe to more than one signal, you need to repeat these steps for all of them.

To disable the saving of a specific signal, use the following command:

> sync disable ecg

Synchronization events

Python
Kotlin
Swift
    def sync_state_did_change(self, aidlab, sync_state):
        pass

    def did_receive_unsynchronized_size(self, aidlab, unsynchronized_size):
        pass

    def did_receive_past_ecg(self, aidlab, timestamp, values):
        pass

    def did_receive_past_respiration(self, aidlab, timestamp, values):
        pass

    def did_receive_past_skin_temperature(self, aidlab, timestamp, value):
        pass

    def did_receive_past_heart_rate(self, aidlab, timestamp, hrv, heart_rate):
        pass

    def did_receive_past_respiration_rate(self, aidlab, timestamp, value):
        pass
    
    def did_receive_past_activity(self, aidlab, timestamp, activity):
        pass

    def did_receive_past_steps(self, aidlab, timestamp, value):
        pass
interface AidlabSynchronizationDelegate {

    fun syncStateDidChange(aidlab: IAidlab, state: SyncState)

    fun didReceivePastECG(aidlab: IAidlab, timestamp: Long, values: FloatArray)

    fun didReceivePastRespiration(aidlab: IAidlab, timestamp: Long, values: FloatArray)

    fun didReceivePastSkinTemperature(aidlab: IAidlab, timestamp: Long, value: Float)

    fun didReceivePastHeartRate(aidlab: IAidlab, timestamp: Long, hrv: IntArray, heartRate: Int)

    fun didReceiveUnsynchronizedSize(aidlab: IAidlab, unsynchronizedSize: Int)

    fun didReceivePastRespirationRate(aidlab: IAidlab, timestamp: Long, value: Int)

    fun didReceivePastActivity(aidlab: IAidlab, timestamp: Long, activity: ActivityType)

    fun didReceivePastSteps(aidlab: IAidlab, timestamp: Long, value: Long)
}
public protocol AidlabSynchronizationDelegate: class {

    func syncStateDidChange(_ aidlab: IAidlab, state: SyncState)
    
    func didReceivePastECG(_ aidlab: IAidlab, timestamp: UInt64, values: [Float])

    func didReceivePastRespiration(_ aidlab: IAidlab, timestamp: UInt64, values: [Float])

    func didReceivePastSkinTemperature(_ aidlab: IAidlab, timestamp: UInt64, value: Float)

    func didReceivePastHeartRate(_ aidlab: IAidlab, timestamp: UInt64, hrv: [Int32], heartRate: Int32)
    
    func didReceiveUnsynchronizedSize(_ aidlab: IAidlab, unsynchronizedSize: UInt16)
    
    func didReceivePastRespirationRate(_ aidlab: IAidlab, timestamp: UInt64, value: UInt32)
    
    func didReceivePastActivity(_ aidlab: IAidlab, timestamp: UInt64, activity: ActivityType)
    
    func didReceivePastSteps(_ aidlab: IAidlab, timestamp: UInt64, value: UInt64)
}

results matching ""

    No results matching ""