Showing results for 
Search instead for 
Did you mean: 

Temperature Conversion - from the LIS3DH sensor raw value

Surya S
Associate II

Hello All,

Need to read the values from the embedded Temperature Sensor in LIS3DH via I2C communication 

I had made the following configurations as mentioned in the datasheet,

1. CTRL_REG4(0x23) = 0X80

2. TEMP_CFG_REF (1Fh) = 0XC0

3. Trying read the temperature value from the following register OUT_ADC_3_L(0x0C) and OUT_ADC_3_H(0x0D).

     - Getting the value from the OUT_ADC_3_H(0x0D) as 8. If I expose heat near to the chip the value is increasing. 

How to convert this(8) value to temperature?

Kindly assist me to get the conversation formula. Here the Vdd supply = 3.3V.


Thanks in Advance.



Surya S 


Federica Bossi
ST Employee

Hi @Surya S ,

As reported in Table 5 of the datasheet, the temperature sensor output change vs temperature: 1 digit/degree of Celsius.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

@Federica Bossi ,


Thank you for the update.


Here the thing is the unit we kept the unit under room temperature 25°C and the value read from the register OUT_ADC_3_H(0x0D) is 7. How can equate this  8 to 25°C? Attached image is for your reference.



Thanks In Advance.


You should be able to read both the low and high byte in a singular 2 byte read operation. What's that number pair?

Post code section using the ... </> tool in the post edit window, not as a bitmap

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..


Please find the code


ADSwrite[0] = 0x1f;

ADSwrite[1] = 0xC0;


if (HAL_I2C_Master_Transmit(&hi2c2, address << 1, ADSwrite,2, 1000) == HAL_OK)


if (HAL_I2C_Master_Receive(&hi2c2, address << 1, ADSread, 2, 1000) != HAL_OK)



reg = 0X0C;

if (HAL_I2C_Master_Transmit(&hi2c2, address << 1, &reg, 1, I2C_HAL_API_TIMEOUT) != HAL_ERROR)


if (HAL_I2C_Master_Receive(&hi2c2, address << 1, &lowByte, 1, 1000) != HAL_OK)




reg |= 0x01;

if (HAL_I2C_Master_Transmit(&hi2c2, address << 1, &reg, 1, I2C_HAL_API_TIMEOUT) != HAL_ERROR)


if (HAL_I2C_Master_Receive(&hi2c2, address << 1, &highByte, 1, 1000) != HAL_OK)

{ }


adcData = (highByte << 8) | lowByte;