We're using the LIS2HH12 accelerometer and there's a temperature sensor listed in the datasheet accessible via the temp_L and temp_H registers (16 bits).

However the numbers I get don't make any sense.

The datasheet mentions "Temperature sensor output change vs. temperature" of 8 digit/°C

11-bit resolution, -40 to 80C range and that the it uses two's complement, but I can't find a way to make the readings return any meaningful value.

What do these temp_L and temp_H numbers really mean? Thank you.

I think Jose is asking for the data interpretation. I would also appreciate a more detailed description in the datasheet.

TEMP_H:TEMP_L is the raw sensor output - a signed 16-bit number, stored as two's complement.

At 25 centigrades, the output is 0. For every centigrade, the sensor output value changes for 8 LSBs, meaning 1 LSB is a 0,125 centigrades change (2 LSBs 0,25 centigrades, 4 LSBs 0,5 centigrades etc.).

So the basic formula is:

TEMP_H:TEMP_L + temp_offset_25_centigrades = measured_temperature(Please note that negative TEMP_H:TEMP_L value doesn't necessarily mean a negative temperature.)

I personally display 2 decimal digits in my applications, but use integer variables to keep the code fast and clean, so I read the sensor output data like this:

int16_t tempHex = (temp_h << 8) | temp_l;and then do the following computation: multiply the sensor output value by TEMP_FRACTION_MULTIPLIER = 125 and divide it with TEMP_FRACTION_DIVIDER = 10. This way the value stored in the temperature register contains temperature value multiplied by a hunded (12.34 centigrades is stored as 1234 etc.). TEMP_OFFSET = 2500 (for 25.00 centigrades).

int32_t temperature = ((tempHex * TEMP_FRACTION_MULTIPLIER) / TEMP_FRACTION_DIVIDER) + TEMP_OFFSET;Or you can just divide TEMP_H:TEMP_L by 8 (shift by 3 positions to the right), discard the decimal points and use only the round value of centigrades. (You still need to add the offset of 25 centigrades.)

Hope this helps a bit.