[Need advise] ECG Analyzer

Hi~ Guys

Anyone in here who followed this project?

I just wodering few things, I need some advise for someone who if know about this project.

  1. What is the “edge-impulse-daemon --frequency 202” code mean?

  2. He used ‘Aruduino nano 33 BLE sens’ and ‘AD8232 ECG sensor’ , and I use those too,
    Am I need "edge-impulse-data-forwarder’ ? beacuse I can’t find AD8232 sensor at sensor categories

I hope you stay health this time!

Chanho

Hello @bongchanho,

  1. The --frequency option does not exist with edge-impulse-daemon. It is a small mistake in the tutorial :wink:
  2. Correct, you need to use the edge-impulse-data-forwarder because the ECG sensor is not supported by the default firmware we are providing. And with the data forwarder you can overide the frequency (such as edge-impulse-data-forwarder --frequency 202)

Regards,

Louis

Hi again! @louis

Oh…you are my shining star … :star_struck:

Final Question,
I want upload ECG frequency file. (matlab file that make up of lot of numbers)
Can I use it if I convert to python to ‘training data’?

Love you!

Chanho

Hello @bongchanho,

I haven’t used matlab for a very long time now but I am pretty sure you could adapt the following script from our data acquisition format documentation to matlab format using something similar to this https://www.mathworks.com/matlabcentral/answers/499434-matlab-http-post-and-json-request

Here is the example in Python on how to use our API to push some data:

 # First, install the dependencies via:
#    $ pip3 install requests

import json
import time, hmac, hashlib
import requests

HMAC_KEY = "fed53116f20684c067774ebf9e7bcbdc"
API_KEY = "ei_fd83..."

# empty signature (all zeros). HS256 gives 32 byte signature, and we encode in hex, so we need 64 characters here
emptySignature = ''.join(['0'] * 64)

data = {
    "protected": {
        "ver": "v1",
        "alg": "HS256",
        "iat": time.time() # epoch time, seconds since 1970
    },
    "signature": emptySignature,
    "payload": {
        "device_name": "ac:87:a3:0a:2d:1b",
        "device_type": "DISCO-L475VG-IOT01A",
        "interval_ms": 10,
        "sensors": [
            { "name": "accX", "units": "m/s2" },
            { "name": "accY", "units": "m/s2" },
            { "name": "accZ", "units": "m/s2" }
        ],
        "values": [
            [ -9.81, 0.03, 1.21 ],
            [ -9.83, 0.04, 1.27 ],
            [ -9.12, 0.03, 1.23 ],
            [ -9.14, 0.01, 1.25 ]
        ]
    }
}

# encode in JSON
encoded = json.dumps(data)

# sign message
signature = hmac.new(bytes(HMAC_KEY, 'utf-8'), msg = encoded.encode('utf-8'), digestmod = hashlib.sha256).hexdigest()

# set the signature again in the message, and encode again
data['signature'] = signature
encoded = json.dumps(data)

# and upload the file
res = requests.post(url='https://ingestion.edgeimpulse.com/api/training/data',
                    data=encoded,
                    headers={
                        'Content-Type': 'application/json',
                        'x-file-name': 'idle01',
                        'x-api-key': API_KEY
                    })
if (res.status_code == 200):
    print('Uploaded file to Edge Impulse', res.status_code, res.content)
else:
    print('Failed to upload file to Edge Impulse', res.status_code, res.content)

In the ECG case, it is a time serie so you won’t have any problem adapting the JSON file to send and after feel free to use any of your favorite language to post your JSON using an http request:

Here is how the JSON file should look like:

{
    "protected": {
        "ver": "v1",
        "alg": "HS256",
        "iat": 1564128599
    },
    "signature": "b0ee0572a1984b93b6bc56e6576e2cbbd6bccd65d0c356e26b31bbc9a48210c6",
    "payload": {
        "device_name": "ac:87:a3:0a:2d:1b",
        "device_type": "DISCO-L475VG-IOT01A",
        "interval_ms": 10,
        "sensors": [
            { "name": "accX", "units": "m/s2" },
            { "name": "accY", "units": "m/s2" },
            { "name": "accZ", "units": "m/s2" }
        ],
        "values": [
            [ -9.81, 0.03, 1.21 ],
            [ -9.83, 0.04, 1.27 ],
            [ -9.12, 0.03, 1.23 ],
            [ -9.14, 0.01, 1.25 ]
        ]
    }
}

Regards,

Louis

And if you write a Matlab ingestion script, could you also share it here with the community so everyone familiar with Matlab could adapt it.

Regards,

Louis

Or just use CSV: https://docs.edgeimpulse.com/reference?_ga=2.130381767.93574853.1627901978-1252652237.1574934249#importing-csv-data :slight_smile:

1 Like