Open Nav

Odczytywanie EKG na iOS w czasie rzeczywistym

Author avatar

Jakub Domaszewicz

Ostatnia aktualizacja3 grudnia 2021

Want to capture ECG data from your Aidlab without being tied to a desktop? The latest Aidlab SDK has you covered. Just use the new func didReceiveECG(_ device: Device, timestamp: UInt64, value: Float) method on Aidlab module and you'll get the ECG signal coming in at 500Hz. We know a lot of you have been wanting to analyze ECG data during sports and other athletic activities: now you can.

Note: This tutorial assumes you are familiar with Xcode. If you are not, we encourage you to read Getting Started with Xcode at developer.apple.com

In the tutorial, you’ll start making a simple app that will communicate with Aidlab through Aidlab SDK. By the time you're finished, your app will present the current samples in the console. Later on, you can copy the samples from the console, and paste it to an external file or save it to your iCloud storage using CloudKit.

  1. Create an empty iOS project (Single View App), and set your iPhone as a build target.
  2. Install the Aidlab SDK.

Inside the ViewController.swift, initialize the SDK by setting aidlabManager: AidlabManager? variable:

private var aidlabManager: AidlabManager?

override func viewDidLoad() {

    aidlabManager = AidlabManager(delegate: self)
}

Make sure your ViewController conforms to AidlabSDKDelegate. Inside the body of the didDiscover method, stop the scan, select appropriate signals and connect to Aidlab:

func didDiscover(_ device: Device, rssi: NSNumber) {
    aidlabSDK?.stopScan()
    device.connect(self)
}

Make sure your ViewController conforms to AidlabDelegate. Leave all methods empty, except the didReceiveECG. To read the ECG samples, add a simple print inside the method's body:

func didReceiveECG(_ device: Device, timestamp: UInt64, value: Float) {

    print(value)
}

Compile your project, turn the Aidlab on, and wait up to 3 seconds till you see a green diode blinking rapidly. Now wear Aidlab on your chest, otherwise Aidlab will collect noise.

Note: to determine if Aidlab is positioned correctly, you can use delegate method func wearStateDidChange(_ device: Device, state wearState: WearState).

Your console should be filled with values similar to:

0.0004240349
0.0004235197
0.00042281693
0.00042105225
0.00041855738
0.0004155299
0.00041103555
0.00040524718
0.00039876136
0.00039205124
0.0003836968
0.00037371725
...

These are the ECG samples measured in Volts.

In case you are not happy with the ECG quality, feel free to change the filtering method to aggressive:

device.setECGFiltrationMethod(.aggressive)

Enjoy your untethered ECG data!


Powrót do Bloga

CZYTAJ TAKŻE

Subskrypcja

Zapisz się do naszego newslettera - poinformujemy Cię o wszelkich nowościach i promocjach.

Język

Aidlab's Logo

Aidlab™ jest zarejestrowanym znakiem towarowym. Copyright © 2024

Aidlab™ jest zarejestrowanym znakiem towarowym. Copyright © 2024