Main Content

A wearable low-powered device detects falls using machine learning at the edge. It also monitors the heart rate.

Overview
Falls can result in physical and psychological trauma, especially for the elderly. In order to improve the quality of life of these patients this project presents the development of a fall detection and heart rate monitoring system. The wearable device obtains information from accelerometer and heart rate sensor and sends them to the AWS IoT Core. The fall detection is done offline on the chip using a machine learning algorithm.

Heart Rate Monitoring
This is a simple step and the MAX30105 sensor is connected to the AVR-IOT over I2C connection. The code calculates the average BPM (Beats per minute) and sends to the cloud. We can monitor the heart rate and set a threshold if it goes above or below the safe range it should make an alert.

Fall Detection machine learning model selection
This is a bit complicated. We cannot reliably detect only using the accelerometer raw readings. But we can do it using machine learning. I wanted to use TensorFlow Lite but the AVR-IOT board has only 6KB of RAM and more than 3KB is being used by the AWS IoT Node application. Another option could be using the AWS lambda to do the heavy lifting of the Tensorflow Lite. But I always wanted it to do at the edge. So doing neural network based machine learning is not feasible for such a small memory device but we can do tree based for example Decision Tree or Random Forest classifiers. But again it was a problem. The machine learning model needs at least 2 seconds of 3-axis accelerometer data to reliably predict. If we downsample the 3 axis accelerometer floating point data to 64 samples per second, we need 4 x 3 x 64 x 2 = 1536 bytes to keep the 2 seconds data in a ring buffer. Also, to use the snapshot of the data to extract features we need another 1,536 bytes. So the total is more than 3KB and it would not fit in the RAM. One way to cope up with this problem is to keep the data in a 16-bit (2 bytes) signed integer instead of 4 bytes floating point and multiply it by 100 to keep the precision up to two decimal places. While doing feature extraction we divide the data points by 100 and convert back to the floating point. Using this strategy we need only 1,536 bytes and that would fit in the available RAM. Another problem was the Random Forest model keeps all weights in the code and the available space in the flash memory is only 8 KB since AWS Node application uses almost 93% of the flash. So the Random Forest model can not be stored in the flash. While exploring small size model, I came across a recent algorithm SEFR: A Fast Linear-Time Classifier for Ultra-Low Power Devices which uses only one weight for each feature. I gave it a try and it is tiny by design it could easily fit into the available flash.

Training dataset for fall detection
I used the SisFall: A Fall and Movement Dataset which is a dataset of falls and activities of daily living (ADLs) acquired with accelerometer. It consists of 19 ADLs and 15 fall types performed by 23 young adults, 15 ADL types performed by 14 healthy and independent participants over 62 years old, and data from one participant of 60 years old that performed all ADLs and falls. I used Edge Impulse Studio for feature extraction purpose only. The training was done on the extracted feature using scikit-learn Python library. The trained model was ported to the plain C code using micromlgen Python library. The SEFR algorithm currently supports only binary classification. The SisFall accelerometer data collected using ADXL345 sensor were divided into two classes “Fall” and “Move” and converted to m/s^2 and uploaded to the Edge Impulse Studio. The training was done on the 4 features listed below calculated from the raw data:

Root-mean square (RMS)
Standard deviation
Skewness
Kurtosis
We can see in the Edge Impulse Studio’s Feature explorer (below) the “Fall” and “Move” classes have clear separation using the extracted features.”

Link to article