AnsweredAssumed Answered

LSM303D temperature sensor "12 bit two's complement right aligned"

Question asked by Alistair Buxton on Apr 25, 2018
Latest reply on Apr 25, 2018 by Alistair Buxton

Quote the datasheet:

 

"Temperature data is stored inside TEMP_OUT_L (05h), TEMP_OUT_H (06h) as two’s complement data in 12-bit format, right-justified."

 

So if the sensor value is reading 0 and the temperature drops by 1/8th of a degree, I would expect the value to be 0xffff or 0x0fff - that is 0bxxxx111111111111. Since 111111111111 is 12 bit two's complement for -1, and the x bits are ignored.

 

However this is not the case. The value I actually read is 0xefff / 0b1111111011111111 / -257. The value continues to count down by 1 per 1/8 degree from here.

 

Can anyone explain what is going on here please?

Outcomes