Skip to main content
Visitor II
July 17, 2019
Question

How to decode Temperature value from LIS3DSH Vibration sensor

  • July 17, 2019
  • 1 reply
  • 963 views

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

    This topic has been closed for replies.

    1 reply

    Visitor II
    July 17, 2019

    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;

    }

    ST Employee
    July 22, 2019

    ​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