cancel
Showing results for 
Search instead for 
Did you mean: 

ST BLE Sensor: Project code for the Data recorder app used on SensorTile.box

Bxy
Associate II

Hi, I created a SensorTile.box project in STM32CubeIDE in which I am receiving the acceleration data from the LSM6DSOX accelerometer. I would like to convert the data I receive from the sensor into the [mg] unit in the same way it is converted in the Data recorder app which you can download on to the SensorTile.box when using the ST BLE Sensor app. Thats why I am wondering if there is any Project code for the Data recorder app, where I could see how the calculation is performed. (I require the same kind of data because I have taught a machine learning model on data received from using the Data recorder app)

I have set the accelerometer to work at 104 Hz and 4g. My current calculation of accelerometer data is based off of the code I found in the SensorTileBox-BLESensors project from the FP-SNS-STBOX1 function pack. Here is the code (for the X axis, Y and Z are also calculated like X) I am using to get the acceleration data and convert it to the [mg] unit:

Bxy_2-1687033694316.png
Bxy_1-1687033611185.png

Bxy_3-1687033865623.png

Bxy_4-1687034024661.png

For instance the data I received from the app while the SensorTile.box was stationary, was around 993 mg on the Z axis. When I used my own project and the SensorTile.box was in the same position, the data was around 960 mg on the Z axis. That is why I am assuming that I am not converting the data correctly. 

Thank you in advance.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Federica Bossi
ST Employee

Hi @Bxy ,

Lookig at your code, you write:

FedericaBossi_0-1687180312282.png

the correct form should be:

int16_t     AccelX;

int32_t      AccelX_mg:

AccelX= ((int16)AccelX1 <<8 ) | AccelX2);

AccelX_mg= (int32_t)((float)AccelX * LSM6DSOX_ACC_SENSITIVITY_FS_4G);

If this solves your problem, please mark my answer as "Accept as Solution" by clicking on the "Select as Best" button, this can be helpful for Community users to find this solution faster 🙂

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

6 REPLIES 6
RhSilicon
Lead

Interesting, I didn't know about this IC, maybe I can compare it with the MPU-6050, which is used a lot by the Arduino community, it has a lot of libraries too.

I also found these videos, if you haven't seen them, they usually help, the ST channel on YouTube has many videos about the products:

[LSM6DSOX Step-By-Step Tutorial, Part 1 of 5: Introduction]:

https://www.youtube.com/watch?v=QDjdtsR5fv8

Bxy
Associate II

Thank you, but I require the calculation that is used in the Data recorder app to get the data in [mg] units and probably also the settings at which the accelerometer inside LSM6DSOX is running at. I am using the machine learning model through X-CUBE-AI, so the tutorial videos arent exactly helpful for that, nor are the others that I found that do use X-CUBE-AI.

Federica Bossi
ST Employee

Hi @Bxy ,

Lookig at your code, you write:

FedericaBossi_0-1687180312282.png

the correct form should be:

int16_t     AccelX;

int32_t      AccelX_mg:

AccelX= ((int16)AccelX1 <<8 ) | AccelX2);

AccelX_mg= (int32_t)((float)AccelX * LSM6DSOX_ACC_SENSITIVITY_FS_4G);

If this solves your problem, please mark my answer as "Accept as Solution" by clicking on the "Select as Best" button, this can be helpful for Community users to find this solution faster 🙂

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Thank you, I seem to be getting just about the same values now.

Before I accept the solution I would like to also ask if you know what settings are being used on the LSM6DSOX (which values are being sent to which registers to set up the accelerometer), when I choose to use the Data recorder app from the ST BLE Sensor app. The settings in the Data recorder app for the IMU Accelerometer sensor are: 0 minutes Acquisition Time, Low power Power mode, 104 Hz ODR and 4 g FS. 

Because currently, I am just setting the accelerometer to 104 Hz ODR and 4 g FS as such ( in the CTRL1_XL register):

Bxy_0-1687203837262.png

I would also guess that Low power Power mode means disabling high-performance operating mode in the CTRL6_C register like this:

Bxy_1-1687204524268.png

So I would appreciate it a lot if you could tell me how the LSM6DSOX is being set up when using the app. Again thank you very much for your help.

Ciao @Bxy ,

The settings you use are the same of the app, because the fw performs the same operations.

The only difference could be in the ODR: the setting for the sensor is the same (write 0x48 in register 0x10) but for some ODRs the timer at which the data is read/written is slightly different (for example it could be 100 instead of 104)

If this difference is important to you I can check with the dedicated team and let you know.

If this helps you, please mark my answer as "Best Answer" by clicking on the "Accept as Solution" button, this can be helpful for Community users to find this solution faster.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

No thank you. If those are the same settings used in the LSM6DSOX registers, I doubt I would be receiving any different acceleration values compared to the app.

Thank you for your help.