2018-05-17 09:00 AM
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
#lsm303agrSolved! Go to Solution.
2018-05-17 01:29 PM
Have you also set BDU bit in register
CTRL_REG4? Combined with 0xC0 in
TEMP_CFG_REG it works for me.
OUT_TEMP_L
andOUT_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.
2018-05-17 01:29 PM
Have you also set BDU bit in register
CTRL_REG4? Combined with 0xC0 in
TEMP_CFG_REG it works for me.
OUT_TEMP_L
andOUT_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.
2018-05-18 12:39 PM
Hello Rastislav,
Many thanks for your helpful answer, the values make sense now.
My bad, writing0xC0 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 inOUT_TEMP_H can always be read as degrees, irrelevant of the power mode, which is consistent with the datasheet.
Thank you
2018-05-18 12:47 PM
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.
2018-05-19 03:37 AM
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 readOUT_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_Hperhaps the extra sensibility doesn't make much sense, even if in my testing it seemed consistent.
2018-05-25 03:31 AM
Thank you for your test, with 0.25°C resolution the temperature sensor can make more sense in some deployments.