Skip to main content
Visitor II
February 6, 2024
Solved

LSM303AGR gives weird values output of the accelerometer

  • February 6, 2024
  • 1 reply
  • 1832 views

Hi,
I am using examples from the github repo to test accelerometer. I can read device id from both accel and magnetometer. Also I can read back the registers I set.  However, when it comes to read accelerometer, I read same values from all axis of the accelerometer such as A0A0A0 or 808080 and so on. Another behavior I observed is sometimes, boot register stuck as 1 after I use to BOOT bit from CTRL_REG5_A.
Also I read very low values from magnetometer and 0 from temperature sensor.
Is there any idea what is going wrong?

Thanks.

    This topic has been closed for replies.
    Best answer by Selim Sagir

    Hi @Federica Bossi ,
    I think problem is the auto address incrementation for the multiple reads. Because when I've read the axis out registers one by one, I can see correct values. Also when I changed to LSM303AGR_OUT_X_L_A (0x28) to 0xA8, library function (lsm303agr_temperature_raw_get) also gives correct outcomes
    Thanks,
    Selim.

    1 reply

    Technical Moderator
    February 7, 2024

    Hi @Selim Sagir ,

    Have you made any changes to the examples on github or are you using them as they are loaded?

    Selim SagirAuthorAnswer
    Visitor II
    February 7, 2024

    Hi @Federica Bossi ,
    I think problem is the auto address incrementation for the multiple reads. Because when I've read the axis out registers one by one, I can see correct values. Also when I changed to LSM303AGR_OUT_X_L_A (0x28) to 0xA8, library function (lsm303agr_temperature_raw_get) also gives correct outcomes
    Thanks,
    Selim.

    Technical Moderator
    February 7, 2024

    Hi @Selim Sagir ,

    Ok, so have you found how to solve this issue?