Skip to main content
Visitor II
March 13, 2024
Question

LIS3DH using I2C HAL - Not reading acceleration data

  • March 13, 2024
  • 2 replies
  • 1530 views

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)

    This topic has been closed for replies.

    2 replies

    Super User
    March 13, 2024

    > 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.

    LaraCSAuthor
    Visitor II
    March 22, 2024

    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

    Graduate II
    March 13, 2024

    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

    LaraCSAuthor
    Visitor II
    March 22, 2024

    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?