cancel
Showing results for 
Search instead for 
Did you mean: 

IIS2DLPC temperature sesnor 12 bit value. How to convert from 12 bit raw value to °C?

User_of_Sensor
Associate II

How can i convert 12 bit raw value from 0x0D & 0x0E to degree celsius?

2 REPLIES 2
Eleon BORLINI
ST Employee

Hi @User_of_Sensor​ , you have first to concatenate the OUT_T_L (0Dh) and the OUT_T_H (0Eh) register (16 bits). Then you consider only the first 12 bits, converting it in decimal value using 2's complement, divide for the sensitivity of 16LSB/°C and finally sum it to 25°C. You can find the driver code here

float_t iis2dlpc_from_lsb_to_celsius(int16_t lsb)
{
  return (((float_t)lsb / 16.0f) + 25.0f);
}

Regards

Hello @Eleon BORLINI​ ,

Thank you for the reply. It works! Great

Best regards,