1
\$\begingroup\$

I am using a LSM303DLHC and am very confident I have the I2C communication working well. I am now trying to use the devices 12 bit temperature sensor. The datasheet is not clear and the tech support is not that fast.

The datasheet parameter, TSDr, described as "Temperature sensor output change vs. temperature" has a typical value of "8 LSB/°C".

That seems to suggest to me that a temperature reading of 1 (just single bit high) would be 1/8th of 1 deg C. A value of 8 would be 1 deg C.

That does not work out over a range of temperatures. I don't have access to an accurate thermometer, but it it's clear it'd not as simple as that.

Hoping someone reading this might have already figured this out.

\$\endgroup\$
  • \$\begingroup\$ What are you getting for room temperature? \$\endgroup\$ – Nick Alexeev Feb 24 '16 at 1:01
  • \$\begingroup\$ @Allan: Did you find the solution? \$\endgroup\$ – Arnaud F. Mar 26 '17 at 8:48
2
\$\begingroup\$

[I don't have hands-on experience with this accelerometer. The following is based solely on reading the datasheet.]

Check section 7.2.9 in the datasheet. I suspect that you are not discarding the lower 4 bits of TEMP_OUT_L_M register.

enter image description here

\$\endgroup\$
1
\$\begingroup\$

I also had this problem today, and solved it.

The sensor reading has to be: a) byte-swapped, as it comes in big-endian order b) shifted right by 4 to push out the unused lower zeros c) added 20 degrees Celsius, because "0" is calibrated at this temperature

C code:

// this is a temporary storage where TEMP_OUT_H_M and TEMP_OUT_L_M
// are read sequentially
uint16_t temp_h_l;

// Normalize temperature; it is big-endian, fixed-point
// 9 bits signed integer, 3 bits fractional part, 4 bits zeros
// and is relative to 20 degrees Celsius
temperature = (20 << 3) + (((int16_t)bswap16 (temp_h_l)) >> 4);

The termometer seems fairly precise, I've compared it to my multimeter's bimetallic temperature sensor and it shows quite similar values. I've used a hair dryer to get temperatures up to 60-70 degrees, and some ice to get temperatures down to 0 degrees, the output of both sensor was around +-1 degree from each other.

\$\endgroup\$
  • \$\begingroup\$ This 'me-too' answer is correct, but much to late to help the OP after 2 years have passed. \$\endgroup\$ – Sparky256 Feb 18 '18 at 22:02
  • \$\begingroup\$ Where did you read in the datasheet that 20°C is calibrated at 0? I only read "@ Vdd = 2.5 V, T = 25 °C unless otherwise noted (b)." \$\endgroup\$ – axello May 8 at 12:36
0
\$\begingroup\$

Pg 39 of the datasheet tells us that the value is a 2's complement number.
So 11 bits + 1 sign bit gives us a range of -2048 to +2047.
8 steps per degree means -256 to +255.875 degrees.
The table of specs on pg 11 give an operating range of -40 to +85 degrees - well within the range of reportable values.
So there shouldn't be any problem...

\$\endgroup\$
  • 1
    \$\begingroup\$ Thank you for your reply ! I was aware of the data arrangement in the registers, and was treating it as a 12 bit signed value. Considering all that, the values still seem to not reflect true temperature. I thought there might be an offset, but could not determine it. \$\endgroup\$ – Allan Feb 27 '16 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.