Skip to main content
Visitor II
June 9, 2017
Question

IIS2DH read temperature

  • June 9, 2017
  • 2 replies
  • 893 views
Posted on June 09, 2017 at 12:56

I want to read the temperature from IIS2DH over I2C

I set the ODR to 1Hz

set the BDU bit in Ctrl Reg 4

enable the Temerature sensor in TEMP_CFG_REG

after the initialization I read the STATUS_REG_AUX and the value of this register is every time 0xFF

and the OUT_TEMP_L and OUT_TEMP_H register are 0x00

    This topic has been closed for replies.

    2 replies

    ST Employee
    June 12, 2017
    Posted on June 12, 2017 at 11:25

    Please be aware the temperature sensor does not return absolute temperature value. See my answer in this topic 

    https://community.st.com/0D50X00009XkY6DSAV

     it is valid also for the IIS2DH.

    You configuration is correct, just to be sure, you can share with me the exact value which you write in the registers.

    There is a possibility that the ambient temperature is exactly the same as the reference value so the difference is 0 so your measurement would be correct.

    Did you try ho heat up or cool down the sensor?

    Visitor II
    June 12, 2017
    Posted on June 12, 2017 at 13:04

    we found the problem this morning. A colleg fount a note in a forum. The problem was, that I not set the MSB Bit in the register address to read multiple registers. The values only updated when the two bytes of the measurement values are readed.

    Visitor II
    July 12, 2018
    Posted on July 12, 2018 at 14:02

    Dear Kleemann Wolfganag, I have the same problem exactly. Firstly  I am reading  

    OUT_TEMP_H register, then 

    OUT_TEMP_L register,  and combining them (bellow you can see the code). but it is not working. Could you tell me what I need to do in this situation.

    Thank you.

    int16_t MKI168V1::read(uint8_t addressh, uint8_t addressl)

    {

    int data, t_data;

    Wire.beginTransmission(Accel_Address);

    Wire.write(addressh);

    Wire.endTransmission();

    Wire.requestFrom(Accel_Address, 1);

    if(Wire.available() > 0)

    {

    t_data = Wire.read();

    data = t_data << 8;

    }

    Wire.beginTransmission(Accel_Address);

    Wire.write(addressl);

    Wire.endTransmission();

    Wire.requestFrom(Accel_Address, 1);

    if(Wire.available() > 0)

    {

    data |= Wire.read();

    }

    return data;

    double MKI168V1::getTemperature()

    {

    double temp;

    temp = read(OUT_TEMP_H, OUT_TEMP_L);

    return(temp);

    }