Skip to main content
Visitor II
April 6, 2020
Question

How to convert the LSM303AGR Accelerometer temperature from the 2 registers to Celsius Degrees

  • April 6, 2020
  • 1 reply
  • 796 views

Hi,

I am developing a device that uses the accelerometer/magnetometer LSM303AGR.

The problem is that datasheet doesn´t comment about temperature sensibility (For example: Sensitivity = 16 LSB/°C in lis2dtw12)

Could anyone give me an equation to convert the output temperature for the temperature registers of the LSM303AGR to Celisus Degrees?

Thanks in advance

    This topic has been closed for replies.

    1 reply

    ST Employee
    April 6, 2020

    Hi @Jorge González​ , you can refer to the github C drivers for the LSM303AGR device, provided by ST (LINK)

    float_t lsm303agr_from_lsb_nm_to_celsius(int16_t lsb)
    {
     return ( ( (float_t)lsb / 64.0f ) / 4.0f ) + 25.0f;
    }

    The datasheet (p. 15 and 46) reports that the temperature value is in 8-bit resolution and is obtained concatenating the OUT_TEMP_L_A (0Ch) and the OUT_TEMP_H_A (0Dh) registers, two's complement conversion on 16bit, 1°C per LSB centered around the typical test temperature, 25°C. For this reason, you see the 64*4 = 2^8 division (8bit), the float casting (two's complement) and the 25°C sum.

    Regards