HealthyPi 5

An extensible, open-source sensor platform for biosignal acquisition

Limited items in stock

View Purchasing Options
Jun 09, 2023

Project update 6 of 11

Edge-AI Data Acquistion & Inference Using HealthyPi 5 & Edge Impulse

by Ashwin W

HealthyPi 5 is a versatile device that can be used for a variety of applications. One of the most common applications is to use HealthyPi 5 as a data-acquisition device for collecting physiological data. HealthyPi 5 can also be used as a platform for edge-AI inference, where the data is collected and processed on the device itself before being classified according to a machine learning model. In this post, we will look at how to use HealthyPi 5 with the Edge Impulse platform for edge-AI data acquisition and inference. Support for Edge Impulse is being integrated directly into the HealthyPi Zephyr application and will be available in the next release.

Collecting data using HealthyPi 5

Edge Impulse is a platform for developing, training and deploying machine learning models on edge devices. The Edge Impulse platform can be used to develop machine learning models for a variety of applications including audio, vision, motion and other sensor data. The Edge Impulse platform also provides a complete workflow for deploying the machine learning models on edge devices. Check our more details about the Edge Impulse platform here in their docs.

Edge impulse provides a convenient command line tool for most desktop platforms called the Data Forwarder which can be used to collect data from a variety of sensors and send it to the Edge Impulse platform for training and inference. The HealthyPi 5 Zephyr application now supports the streaming of data over the USB interface and the data forwarder can be used to acquire data from HealthyPi 5 and send it to the Edge Impulse platform for training and inference. You will need to create an Free account on Edge Impulse to use the data forwarder. Once you login to Edge Impulse from the command line using your credentials, you can configure it as a data source as showing in the following figure.

The Data Source shows up in the Edge Impulse Dashboard as shown below. You can now start sampling data from HealthyPi 5 and send it to the Edge Impulse platform for feature extraction and training. The following figure shows the sampling module on the far right corner. Simply click "Start sampling" now and it starts collecting data from HealthyPi 5. The dashboard also provides a WebUSB interface for USB devices, which can be used to connect to HealthyPi 5 directly from the browser, but we could not try it out this time.

As soon as the sampling starts on the platform, the data forwarder should now show that a client is connected and data is being received from HealthyPi 5, as shown in the following figure.

(image error)

The data from HealthyPi 5 now starts streaming into the Edge Impulse platform! It really is that simple! The following figure shows the data being collected from HealthyPi 5 (in realtime). Data can currently be collected from the ECG, PPG, Respiration and other sensors that may be connected to the QWIIC Interface of HealthyPi 5. The following figure shows the data being collected from the PPG sensor’s RED signal.

Training a model using the data from HealthyPi 5

Once the data is collected, it can be used to train a machine learning model. Edge Impulse now allows you to create an "Impulse", their version of a model using the Impulse designer platform. This screen allows you to select the data that you want to use for training the model and the features that need to be extracted. For this example, we have only chosen some spectral parameters. The following figure shows the Impulse designer screen.

After selecting the parameters, labels and features, you can now start training the model. The following figure shows the training screen. For the example here, just as a quick test, we are using the PPG data to detect if the subject is:

We have taken 10-second samples of each label and trained the model using 10 samples of each label. This is a not meant to be a robust model, but just a quick test to see if the model can be trained using the data collected from HealthyPi 5. It’s time to train the model now.

As you can see, the model is not very accurate since it was trained using a very small dataset. However, it is sufficient to demonstrate the concept. The following figure shows the model being tested using the data collected from HealthyPi 5.

Testing the model

The following figure shows the model being tested using the data collected from HealthyPi 5. The following figure shows the model being tested using the data collected again using the forwarder application from HealthyPi 5, but this time in classification mode. The model is able to identify the three labels that we have trained it on, but confidence is low since the model was trained using a very small dataset.

The model is ready to deployed to HealthyPi 5 as a Tensorflow Lite model for edge inference. The model is available to be downloaded as a set of C++ libraries that contains the edge impulse sdk and the trained model data, which can be compiled and deployed on HealthyPi 5.

This post has attempted to show the data acquisition and training workflow for using HealthyPi 5 as a platform for edge AI. The model was trained on a very small dataset and is not closed to being directly usable, but provides a starting point for further exploration.

Deployment of the model on HealthyPi 5 will be covered in a future post. The next stage of the process would be to deploy the model on HealthyPi 5 and test it on the device itself and we will cover that in detail in a future post. Edge Impulse has provided a sample implementation on Zephyr here.Stay tuned for the next post in this series to see how to deploy the model on HealthyPi 5 and test it on the device itself.

Meanwhile, get in touch with us if you have any comments, questions or suggestions. We would love to hear from you!


Sign up to receive future updates for HealthyPi 5.

Subscribe to the Crowd Supply newsletter, highlighting the latest creators and projects