cancel
Showing results for 
Search instead for 
Did you mean: 

LSM303AGR Temperature Measurements

Guillaume Reinhardt
Associate II
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
1 ACCEPTED SOLUTION

Accepted Solutions
Rastislav Wartiak
Associate II
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.

View solution in original post

5 REPLIES 5
Rastislav Wartiak
Associate II
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.

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

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.

Posted on May 19, 2018 at 10:37

Ok, actually I did some quick tests (temperature variations) in low power and in normal mode. 

That's how I noticed that we can always read 

OUT_TEMP_H

 in degrees (we get the same results irrelevant of the power mode). 

So in normal/high-res mode, if we read both registers ( we add 2 digits 

), sensibility is then 0.25°C/digit. 

Given that the datasheet says to always read only OUT_TEMP_H

  perhaps the extra sensibility doesn't make much sense, even if in my testing it seemed consistent.

Posted on May 25, 2018 at 10:31

Thank you for your test, with 0.25°C resolution the temperature sensor can make more sense in some deployments.