2020-09-28 08:54 AM
Hi all,
I'm currently deploying hardware that can have either the LIS2HH12 or IIS2DLPC
According to the datasheet the LIS2HH12 stores the temperature as two's complement / 11 bit / 8 digit per degrees celcius.
So I convert it this way:
int16_t tilt_read_temp(void)
{
uint8_t temperature[2];
int32_t temp;
lis2hh12_temperature_raw_get(&dev_ctx, temperature);
temp = (temperature[1] << 8) | temperature[0];
temp = temp>>5;
temp = ((temp * 125) / 10) + 2500;
temp = temp / 10;
return temp;
}
This gives me 211 my notation for 21.1 degrees
The other sensor IIS2DLPC should be 12 bits, two's complement 16 lsb per degrees celcius.
So I convert that one as:
int16_t tilt_read_temp(void)
{
uint8_t temperature[2];
int32_t temp;
iis2dlpc_temperature_raw_get(&dev_ctx, temperature);
temp = (temperature[1] << 8) | temperature[0];
temp = temp>>4;
temp = ((temp * 625) / 100) + 2500;
temp = temp / 10;
return temp;
}
But this one returns 273, my notation for 27.3 degrees celcius.
Both boards are in the same room and I think 21 degrees is most likely the temperature in the room.
Am I converting the last one wrong?
BTW: I'm running both on 3.3v supply
Solved! Go to Solution.
2021-04-21 07:42 AM
Hi @WSpar.1 ,
maybe the values you are receiving are correct... while the Github code calculation is wrong.
As reported in the datasheet:
So, basically you have to further divide
The conversion formula gives actually the following:
which looks a little more plausible for an ambient temperature...
I will report it internally...
-Eleon
2020-09-29 06:41 AM
Hi @WSpar.1 ,
do you have the possibility to compare the temperature measure from other similar devices?
Btw, your temperature decoding seems ok, comparing it also with the ST C drivers on Github
For example for the LIS2HH12 you have (lis2hh12_reg.c:(
float_t lis2hh12_from_lsb_to_celsius(int16_t lsb)
{
return (((float_t)lsb / 8.0f) + 25.0f);
}
While for the IIS2DLPC (iis2dlpc_reg.c:(
float_t iis2dlpc_from_lsb_to_celsius(int16_t lsb)
{
return (((float_t)lsb / 16.0f) + 25.0f);
}
I agree with you that the 21°C is most probably the correct value, considering also that, as reported in the IIS2DLPC datasheet, there could be a temperature offset of a few degrees.
-Eleon
2020-09-29 07:48 AM
Yes a 3th device measured around 21 degrees.
I noticed both datasheet have the 25 degrees / 0 LSB point measured with different supply voltage.
One is measured with 1.8v and the other 2.5v supply voltage
2020-09-29 08:27 AM
The 3rd device is another LIS2HH12, an IIS2DLPC or an external reference?
Ps: there should not be such a dependency of the temperature with the power supply voltage...
-Eleon
2020-09-29 09:55 AM
Yes just the room thermostat.
Is my bit shifting correct?
2020-09-30 08:44 AM
It should, but please try also with the other two formulas.
Tks
-Eleon
2021-04-19 10:29 AM
Can someone help me out to what degrees of Celsius this should convert?
My code converts this into somewhere around 60 degrees (didn't log it exactly)
When reading the temperature every 500 ms, I'm seeing massive jumps from 34 to 58 degrees.
2021-04-19 11:49 PM
Hi @WSpar.1 ,
did you already tried with the above formulas?
Are you facing this issue for both the sensors in the title of this post?
I'm supposing that the refer to IIS2DLPC device, since the temperature registers are 0D and 0E.
The conversion formula gives actually the following:
That is indeed a little high if you are measuring ambient temperature...
Can you also have the possibility to test other similar devices?
-Eleon
2021-04-20 01:17 AM
Hi Eleon,
LIS2HH12 is not part of our design anymore, because it had 0 stock.
Now we are facing the same stock issues with IIS2DLPC but it should still be in production.
I tried many formulas but the result didn't make any sense.
That is why I moved to scope measurements to be sure it is not a software issue.
On ambient temperature the IIS2DLPC replies with 0230h, and when I hold my finger on the chip I see register 0E increasing to 05, 06
Does manually heat solder this chip easily damage the internal temperature sensor?
Or did I maybe forget to configure the chip properly?
2021-04-20 04:19 AM
Hi Eleon,
I connected a Accel Click board to our device (https://www.mikroe.com/accel-13-click)
These boards are professionally reflowed and is on a different address.
So also very high temperature and fluctuating heavily.