Skip to main content
Visitor II
May 11, 2024
Question

LIS3DH Wrong data

  • May 11, 2024
  • 1 reply
  • 974 views

Hello, 

im having some issues with lis3dh data. 

So im trying to configure and read data from sensor, but its invalid. When i read my buffer L values that are 0 2 4 they seem right: 

HubertW_0-1715434770386.png

But when i try to connect the data or even read 1 3 5 value that are H, its starting sending some values that are 100% incorrect. Im not moving sensor in any direction. 

HubertW_1-1715434821720.png

These are H value. When i connect them. 
x = buffer[0];
x |= ((uint16_t)buffer[1]) << 8;
y = buffer[2];
y |= ((uint16_t)buffer[3]) << 8;
z = buffer[4];
z |= ((uint16_t)buffer[5]) << 8;
doing sth like this the values jump from 32k/16k and 0. 
I have no idea what's going on. Im just sending adress to X_L with setting 1 MSB for auto increment. 
Ofc, ive configured sensor CTRL_REG to turn on normal mode 100Hz XYZ axis ON and 2g. 

And i have some question about FIFO too. I've seen some examples from github. To be precise: lis3dh_multi_read_fifo.c
And ive set it up for my board. Same configuration, functions etc. And i still get wrong data when im connecting H and L. But there is 1 thing that is interesting too me, what's the purpose of using FIFO, when im actually just reading data 25 times 

if (flags) {
/* Read number of sample in FIFO */
lis3dh_fifo_data_level_get(&dev_ctx, &num);

while (num-- > 0) {
/* Read XL samples */
lis3dh_acceleration_raw_get(&dev_ctx, data_raw_acceleration);
acceleration_mg[0] =
lis3dh_from_fs2_hr_to_mg(data_raw_acceleration[0]);
acceleration_mg[1] =
lis3dh_from_fs2_hr_to_mg(data_raw_acceleration[1]);
acceleration_mg[2] =
lis3dh_from_fs2_hr_to_mg(data_raw_acceleration[2]);
sprintf((char *)tx_buffer,
"Acceleration [mg]:%4.2f\t%4.2f\t%4.2f\r\n",
acceleration_mg[0], acceleration_mg[1], acceleration_mg[2]);
tx_com(tx_buffer, strlen((char const *)tx_buffer));
}

 

what's the purpose of Fifo when i can just read data 25 times, is it more energy efficient in this example? 







 

 

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    May 15, 2024

    Hi @HubertW ,

    Welcome to ST Community!

    You can try to follow our PID examples on github.

    Let me know if you still have the problem or if they were helpful.