Skip to main content
Visitor II
May 17, 2018
Solved

LSM303AGR Temperature Measurements

  • May 17, 2018
  • 1 reply
  • 1860 views
Posted on May 17, 2018 at 18:00

Hello, 

I'm using the LSM303AGR, accelerometer and magnetomter, without any problems but now I would like to do some tests with the embedded temperature sensor and datasheet doesn't says much about it.

Firstly could you please confirm the usage of the register TEMP_CFG_REG_A ?

Writing 0xC0 to it, as specified by the datasheet doesn't seem to enable temperature measurements, however writing 0x80 seems to work.

Then could you please clarify the interpretation of the data ? The value is stored in OUT_TEMP_H as two's complement but is there an offset to account for ?

Finally, could this embedded sensor be successfully used to measure ambiant temperature ? Would we need to calibrate each device to obtain an accurate result ?

Thanks for your help,

Guillaume

#lsm303agr
    This topic has been closed for replies.
    Best answer by Rastislav Wartiak
    Posted on May 17, 2018 at 22:29

    Have you also set BDU bit in register 

    CTRL_REG4? Combined with 0xC0 in 

    TEMP_CFG_REG it works for me.

    OUT_TEMP_L

     and 

    OUT_TEMP_H contain the offset from 25 degress C.

    In low-power mode it is enough to use 

    OUT_TEMP_H, only these 8 bits contain the tempature. Just add 25 and treat it as int8_t.

    In high-res and normal mode you need to use whole 16-bit value and shift six times to the right (as signed), as it will contain left-justified 10-bit value. Then again add 25 to get temperature.

    My experience is that this sensor cannot really be used for ambient temperature and the internal temperature will affected by the sensor itself.

    1 reply

    Visitor II
    May 17, 2018
    Posted on May 17, 2018 at 22:29

    Have you also set BDU bit in register 

    CTRL_REG4? Combined with 0xC0 in 

    TEMP_CFG_REG it works for me.

    OUT_TEMP_L

     and 

    OUT_TEMP_H contain the offset from 25 degress C.

    In low-power mode it is enough to use 

    OUT_TEMP_H, only these 8 bits contain the tempature. Just add 25 and treat it as int8_t.

    In high-res and normal mode you need to use whole 16-bit value and shift six times to the right (as signed), as it will contain left-justified 10-bit value. Then again add 25 to get temperature.

    My experience is that this sensor cannot really be used for ambient temperature and the internal temperature will affected by the sensor itself.

    Visitor II
    May 18, 2018
    Posted on May 18, 2018 at 19:39

    Hello Rastislav, 

    Many thanks for your helpful answer, the values make sense now.

    My bad, writing 

    0xC0 in 

    TEMP_CFG_REG is indeed correct, I got confused because I was missing the 25°C offset.

    About the high-res an normal  mode (10bits left justified) do you confirm that the sensibility is then 0.25°C/digit (compared to 1°C/digit in low power mode) ?

    This also means that data in 

    OUT_TEMP_H can always be read as degrees, irrelevant of the power mode, which is consistent with the datasheet.

    Thank you

    Visitor II
    May 18, 2018
    Posted on May 18, 2018 at 19:47

    I've used it only in low power mode, but my understanding is that the resolution is always in degrees, so you'll need both registers. And I don't have the sensor with me right now.