cancel
Showing results for 
Search instead for 
Did you mean: 

LSM6DSM convert registers data to C degree dear all, anyone know how to convert value of OUT_TEMP_L (20h), OUT_TEMP_H (21h) to temperature? My room is 25 deg and I read these OUT_TEMP_H & L = 0xFFFB. thanks and regrads,

tpham.1
Associate II

1 ACCEPTED SOLUTION

Accepted Solutions

Uhm... so basically the temperature increases correctly but it is always 4/5°C below the effective ambient temperature, right? For example, if outdoor is 34°C, the sensor will read 30°C? and same for negative temperatures?

Please note that the Toff (the temperature offset, is declared to be between -15°C and +15°C, so 4/5°C falls in this range. If your offset is constant, you can add it to your Temperature data via SW and apply it to all the temperature range of your interest.

Regards

View solution in original post

8 REPLIES 8
Eleon BORLINI
ST Employee

Hi @tpham.1​ , you can find details on the temperature reading conversion from lsb to celsius on the online available github C driver repository for the LSM6DSM.

lsm6dsm_reg.c

float_t lsm6dsm_from_lsb_to_celsius(int16_t lsb)
{
  return (((float_t)lsb / 256.0f) + 25.0f);
}

In your case:

--> FFFBh --> -4dec (two's complement conversion) --> -0.016 °C (divide by 256) --> 24.984°C (sum 25°C)

Regards

tpham.1
Associate II

Thanks Eleon BORLINI so much,

I found that internal LSM6DSM temperature always lower than ambient about 4-5 °C.

Is it expected?

regards,

Tuyen

Hello Tuyen, no, it is not normal... but if you heat the device (for example with a finger), do you experience a temperature increase above 25°C? (it is important to see 00h or 0xh values instead of FFh in OUT_TEMP_H register) Regards

tpham.1
Associate II

Hi Eleon,

I put it outdoor and saw that it can increase to 30-31°C. If you said it is not normal then any special setting when using internal temperature? value of OUT_TEMP_H always 0xFF

I almost hadn't setting, just write ODR to CTRL1_XL to using accelerator

thanks,

Tuyen

Uhm... so basically the temperature increases correctly but it is always 4/5°C below the effective ambient temperature, right? For example, if outdoor is 34°C, the sensor will read 30°C? and same for negative temperatures?

Please note that the Toff (the temperature offset, is declared to be between -15°C and +15°C, so 4/5°C falls in this range. If your offset is constant, you can add it to your Temperature data via SW and apply it to all the temperature range of your interest.

Regards

tpham.1
Associate II

Uhm... so basically the temperature increases correctly but it is always 4/5°C below the effective ambient temperature, right? For example, if outdoor is 34°C, the sensor will read 30°C? and same for negative temperatures?

--> YES

My purpose is read internal temperature to compensation temperature for raw data accelerator X, Y, Z.

My question is: do I need offset to equal temperature environment or not?

thanks,

>> My question is: do I need offset to equal temperature environment or not?

Yes, the temperature to be used is the environmental temperature.

Regards

RMoha.4
Associate

Hi, I am using the sensor lsm6dsl for reading ambient temperature. I am reading registers OUT_TEMP_L (20h), OUT_TEMP_H (21h). I got the a range of 08 - 0e while reading OUT_TEMP_H and got various values while reading OUT_TEMP_L. I calculated the actual temperature by concatenating the values OUT_TEMP_H and OUT_TEMP_L, Then converted to decimal from signed 2's complement, then divided the value by 256. then added +25. I am getting an output temperature value is +10 more than the actual temperature value. I read from the characteristics temperature offset value can be -15 deg C to +15 deg C, But even what could be the reason for a changes of +10 between reading ambient temp value and sensor temp value.