cancel
Showing results for 
Search instead for 
Did you mean: 

LIS3DH using I2C HAL - Not reading acceleration data

LaraCS
Associate II

Hi everyone,

Based on the drivers from ST GitHub, I developed my own one, but I can't understand why it's not working. I can communicate with the accelerometer and I can read the registers, but I don't know why i am having troubles to read the acceleration data correctly.

It would be nice if someone knows if it's because I'm not writing to the correct registers at the start-up, or because I'm not reading correctly the acceleration data, so the status register is not cleaned. 

Thanks!!

 

I attach below the link to my .zip file of all my project

LaraIMK/LIS3DH_HAL_I2C (github.com)

4 REPLIES 4
TDK
Guru

> I don't know why i am having troubles to read the acceleration data correctly.

What troubles are you having? Since you can read registers, what acceleration values are you seeing and what values are you expecting? Perhaps an issue interpreting twos-complement data.

If you feel a post has answered your question, please click "Accept as Solution".

It's easier to browse code directly in the repo's

Accelerometers need to be enabled in LIS3DH_CTRL_REG1

https://github.com/sparkfun/LIS3DH_Breakout/blob/master/Libraries/Arduino/src/SparkFunLIS3DH.cpp#L439

Check WHO AM I, enable temperature sensor and accelerometers enable/scaling

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
LaraCS
Associate II

I am utilizing an H563ZI board.  I consistently receive identical values for acceleration across all axes, which is not expected behavior. Furthermore, these values remain constant without variation. Additionally, my attempts to utilize the driver provided on GitHub have also yielded unsuccessful results.


Attached are screenshots illustrating the debug output of our program. Figure 1 depicts consistent values for acceleration across all axes, while Figure 2 showcases the initialization registers where we suspect the issue may lie, particularly in the inadequate initialization of certain bits. 

Figure1: acceleration data

image (2).png

Figure 2: initialization

image (3).png

That's what I did (Refering to "Accelerometers need to be enabled in LIS3DH_CTRL_REG1"), but I don't know why it's not working.... My initialization registers are:

image (3).png

And on the other hand, I already attempted to utilize the driver provided on GitHub, but have also yielded unsuccessful results. Do you have/know any full project created with cubeIDE for the LIS3DH sensor?