Arduino Nano BLE 33 Sense IMU

Greetings , i am fairly new in the Embedded Systems world.

I'm trying to create a project using the Arduino Nano BLE 33 Senses' IMU LSM9DS1. This project is a wearable device that requires the usage of the IMU and in particular the (3-axis accelerometer) as a to get measurement data, that detects human activity, and distinguishes between regular human activity (sitting , standing up , walking etc.) and physical exercise(running etc) and transmits the data via SPI to an OLED monitor.
In the past few days i have been trying to find an algorithm or code to do so without any real success. I have found a couple of useful algorithm flowcharts , but i am not sure on how to implement them on my project. (Most of the projects/papers i have read are about pedometer algorithms ). I would really appreciate any kind of assistance.

Thanks in advance.

(Relatable Research Links)

https://www.researchgate.net/publication/329032614_A_More_Reliable_Step_Counter_using_Built-in_Accelerometer_in_Smartphone

https://www.sciencedirect.com/science/article/pii/B978012815369700001X?via%3Dihub

Classifying data can be as complex as you like, depending on your requirements. These days there is a lot of enthusiasm for machine learning, but that requires a training data set.

The place to start would be to set up the Nano BLE Sense to collect accelerometer data, and simply take a look at those data for a variety of human activities. The Serial plotter option (on the Arduino Serial Monitor) can display the three accelerometer variables as a function of time.

Edit: it is useful to display and consider the magnitude of the acceleration vector as well as the components, as the axial directionality is eliminated.

If ax, ay and az are float variables,

float amag = sqrt (ax*ax + ay*ay + az*az);

1 Like

Greetings , thanks for your time & assistance.

I am aware that machine learning is a possible way to solve such issues, but for the time being i would like to keep this project as simple as possible. I have already managed to use the examples provided with the library #include <Arduino_LSM9DS1.h> , and i've previously watched some relevant tutorials. (I've also implemented the amag suggestion!) . Unfortunately , because i'm a new member i cannot provide additional information or links all at once .

#include <Arduino_LSM9DS1.h> 
#define Pi 3.141592654
#define SAMPLE_DELAY 100
#define gaccel 9.8
float pitchOld=0;   
float pitchFNew;    //filtered 


void setup()
{
  Serial.begin(9600);
  while(!Serial);
  Serial.println("Started");

  if(!IMU.begin())
  {
    Serial.println("Failed To Initialize IMU!");
    while(1);
  }
}

void loop()
{
  float x,y,z;
  float pitch;  
  float amag; //magnitude of accel vector

  if(IMU.accelerationAvailable()){
  IMU.readAcceleration(x,y,z);
  pitch=(180/Pi)*atan(x/(z*z + y*y));
  delay(1);
  pitchFNew = (0.95*pitchOld) +(0.05*pitch); //lowpass filter 
  delay(1);
  amag  = sqrt(x*x + y*y + z*z); //magnitude of accel vector
  
  Serial.print("LP Pitch : ");
  Serial.println(pitchFNew);
  Serial.print("aMag : ");
  Serial.print(amag);
  Serial.print('\n');
  }
  delay(SAMPLE_DELAY);
}

Edit: #include <Arduino_LSM9DS1.h> #define Pi 3.141592654#define SAMPLE_DELAY 100 - Pastebin.com (link to my arduino code thus far).
Edit2: I have not included the SPI code as it not relevant for the time being.
Edit3:Fixed Edit1

If you have questions about your code, post it in line, using code tags. Explain what you want it to do and what it does instead.

for the time being i would like to keep this project as simple as possible.

If you figure out a simple way to reliably classify accelerometer data into the categories you mention, many people would be interested.

This topic comes up frequently, and so far, no one seems to think that the problem is simple.

1 Like

Again @jremington thanks for your time & assistance.

As i originally stated, i have read some papers that propose possible solutions but not exactly what i'm hoping to achieve.
I have thought for example that ,(after reading the paper `A More Reliable Step Counter using Built-in Accelerometer in Smartphone & following the algorithm there,) if someone does not stand still and thus(does not get static values) , and if someone is not walking or doing similar activities that produce similar spikes on the serial plotter then he must be exercising . Although i know the principles, code-wise i cannot find a way to make that happen.

Where abs(a) = sqrt(x*x + y*y + z*z)
*Where abs(a) is average acceleration value; X,Y and Z are three axis values. *
The final stage is a key to complete this proposed model, providing the accurate steps. We use a new reliable technique based method of peak. In frequency data of the average acceleration signals, the method finds the peaks points, which is greater than the other points. Then the method checks the number of the occurrence point between two peaks. In which, the number of occurrence points must be greater than two. If the peak point satisfies this condition, it is identified as a one-step. All step points are picked according to the principle rule of the proposed method. The step counting is subsequently taken over one-step to another until reaching the stopping criterion.

The code you posted just collects data. Post your best attempt at code that does the analysis. Or, if you are hoping to find someone to write it for you, there is a forum section specifically for such proposals.

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.