cancel
Showing results for 
Search instead for 
Did you mean: 

How to decode Temperature value from LIS3DSH Vibration sensor

chaitanya chippada
Associate II

Hi,

I am using LIS3DSH Vibration Mems sensor in our project, we need temperature value from sensor. When I read OUT_T register in LIS3DSH , I am getting 0xFE from sensor.

Can, You tell how to decode this value temperature value.

Regards,

chaitanya

2 REPLIES 2
chaitanya chippada
Associate II

I am passing temperature value to twos complement function, I am getting 254, following is the function

int16_t two_compl_to_int16(uint16_t two_compl_value)

{

   int16_t int16_value = 0;

   /* conversion */

   if (two_compl_value > 32768) {

       int16_value = (int16_t)(-(((~two_compl_value) & (uint16_t)(0xFFFF)) + (uint16_t)(1)));

   } else {

       int16_value = (int16_t)(two_compl_value);

   }

   return int16_value;

}

​Hi @chaitanya chippada​ , please consider that for LIS3DSH the temperature is on 8-bit, two's complement, so the function should be something like int8_t two_compl_to_int8. To get the actual temperature value, please consider that the resolution is 1 LSB/deg and 00h corresponds to 25 degrees Celsius. This means that if you read FEh, there will be 25°C + FEh = 25°C - 2°C = 23°C. Is the value FEh changing when you heat the sensor e.g. with a finger? Regards