Skip to main content
Visitor II
August 4, 2016
Question

hts221 returns 0xAE

  • August 4, 2016
  • 4 replies
  • 1053 views
Posted on August 04, 2016 at 10:48

HTS221 after read all humidity registers final value always 29.0% and not changed in time. All data register contain 0xAE values. ST firmware driver for HTS221 also returned 29.0% and 0xAE registers values.

Connection diagram of the standard, according to datasheet

.

Tried several sensors, one and the same. sorry for my english.

    This topic has been closed for replies.

    4 replies

    Visitor II
    August 4, 2016
    Posted on August 04, 2016 at 20:04

    Hello, 

    I am also trying to work with HTS221 sensor and have been posting doubts about the firmware. I would like to know if you have a file called HAL_EnvSensors.h along with the HTS221 firmware. Can you please share the file, in case you have it? 

    Thanks, 

    Visitor II
    August 5, 2016
    Posted on August 05, 2016 at 06:13

    Exchange with sensor tested, working, fixed identifier read correctly (188 or 0xBC) datasheet for both, but the data in the registers are not updated. Having tried all the options register settings. Always one and the same humidity of 29%. The temperature is also fixed. readiness Register reports that are ready the data as temperature and humidity. Apparently the defective batch.

    My code:

    << 

    // ++++++++++++++++++++++++++++++++ HTS221 +++++++++++++++++++++++++++++++++++++

    // Àäðåñ HTS221

    #define HTS221R 0xBF

    #define HTS221W 0xBE

    // Èíèöèàëèçàöèÿ

    void HTS221_Init(void)

    {

                    uint8_t Dat[2];

                   

                    // Ã�àñòðîéêà ðåæèìà è ñêîðîñòè îòäà÷è äàííûõ â 1 Ãö

                    Dat[0] = 0x20;

                    Dat[1] = 0x85;

                    HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 2, 100);

                    // Ã�àñòðîéêà òî÷íîñòè

                    Dat[0] = 0x10;

                    Dat[1] = 0x1B;

                    HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 2, 100);        

    }

    // ×èòàåì âëàæíîñòü

    void HTS221_GetHymidity(void)

    {

                    uint8_t Dat[4];

                    int16_t H0_T0_out, H1_T0_out, H_T_out;

                    int16_t H0_rh, H1_rh;

                    uint32_t tmp;

                    Dat[0] = 0x30;

                    HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 1, 100);

                    HAL_I2C_Master_Receive(&hi2c1, HTS221R, Dat, 2, 100);

                    H0_rh = Dat[0] >> 1;

                    H1_rh = Dat[1] >> 1;

                   

                    Dat[0] = 0x30;

                    HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 1, 100);

                    HAL_I2C_Master_Receive(&hi2c1, HTS221R, Dat, 2, 100);

                    H0_T0_out = (((uint16_t) Dat[1]) << 8) | (uint16_t) Dat[0];

                   

                    Dat[0] = 0x3A;

                    HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 1, 100);

                    HAL_I2C_Master_Receive(&hi2c1, HTS221R, Dat, 2, 100);

                    H1_T0_out = (((uint16_t) Dat[1]) << 8) | (uint16_t) Dat[0];

                   

                    Dat[0] = 0x28;

                    HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 1, 100);

                    HAL_I2C_Master_Receive(&hi2c1, HTS221R, Dat, 2, 100);

                    H_T_out = (((uint16_t)Dat[1]) << 8) | (uint16_t) Dat[0];

                   

                    // Ã�àñ÷åò

                    tmp =((uint32_t)(H_T_out - H0_T0_out)) * ((uint32_t)(H1_rh - H0_rh) * 10);

                    CHymidity = tmp / (H1_T0_out - H0_T0_out)  + H0_rh * 10;

                    if (CHymidity > 1000) CHymidity = 1000;

                    CHymidity /= 10.0;

    }

    // Ñòàòóñ

    uint8_t HTS221_GetStatus(void)

    {

                    uint8_t Byte = 0x27;

                    HAL_I2C_Master_Transmit(&hi2c1, HTS221W, &Byte, 1, 100);

                    HAL_I2C_Master_Receive(&hi2c1, HTS221R, &Byte, 1, 100);

                    return Byte;

    }

    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    >>

     

    Visitor II
    August 5, 2016
    Posted on August 05, 2016 at 12:11

    Hi,

    I 've seen your code and I have some suggestions and questions:

    1. In the HTS221_Init should be better change the order of settings, before set the AV_CONF (10h) register and then the CTRL_REG1 (20h) register.

    2. In the HTS221_GetHymidity, I guess there is an mistake.

    To get the H0_T0_out value, you have to read the 0x36 register and not 0x30;

    3. I am not clear where you use the function HTS221_GetStatus.

    Did you call this function and checked that the humidity data is ready before to call the HTS221_GetHymidity?

    Regards

    Antonella

    Visitor II
    August 5, 2016
    Posted on August 05, 2016 at 12:39

    Registers readiness show that the data is ready ! Fixed code , vseravno 29.0 humidity . And with the register read 0xAE. It seems that it is certainly broken sensors .

    This party was sent probes to our company as a sample for review.

    The amount of 3 pieces.

    New corrected code:

    <<

    // Àäðåñ HTS221

    #define HTS221R 0xBF

    #define HTS221W 0xBE

    // Ñòàòóñ

    uint8_t HTS221_GetStatus(void)

    {

                    uint8_t Byte = 0x27;

                    HAL_I2C_Master_Transmit(&hi2c1, HTS221W, &Byte, 1, 100);

                    HAL_I2C_Master_Receive(&hi2c1, HTS221R, &Byte, 1, 100);

                    return Byte;

    }

    // Èíèöèàëèçàöèÿ

    void HTS221_Init(void)

    {

                    uint8_t Dat[2];

                    // Ã�àñòðîéêà òî÷íîñòè

                    Dat[0] = 0x10;

                    Dat[1] = 0x1B;

                    HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 2, 100);        

                   

                    // Ã�àñòðîéêà ðåæèìà è ñêîðîñòè îòäà÷è äàííûõ â 1 Ãö

                    Dat[0] = 0x20;

                    Dat[1] = 0x85;

                    HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 2, 100);

    }

    // ×èòàåì âëàæíîñòü

    void HTS221_GetHymidity(void)

    {

                    uint8_t Dat[4];

                    int16_t H0_T0_out, H1_T0_out, H_T_out;

                    int16_t H0_rh, H1_rh;

                    uint32_t tmp;

                    // Wait for

                    while (HTS221_GetStatus() != 3)

                                   HAL_Delay(5);

                   

                    Dat[0] = 0x30;

                    HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 1, 100);

                    HAL_I2C_Master_Receive(&hi2c1, HTS221R, Dat, 2, 100);

                    H0_rh = Dat[0] >> 1;

                    H1_rh = Dat[1] >> 1;

                   

                    Dat[0] = 0x36;

                    HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 1, 100);

                    HAL_I2C_Master_Receive(&hi2c1, HTS221R, Dat, 2, 100);

                    H0_T0_out = (((uint16_t) Dat[1]) << 8) | (uint16_t) Dat[0];

                   

                    Dat[0] = 0x3A;

                    HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 1, 100);

                    HAL_I2C_Master_Receive(&hi2c1, HTS221R, Dat, 2, 100);

                    H1_T0_out = (((uint16_t) Dat[1]) << 8) | (uint16_t) Dat[0];

                   

                    Dat[0] = 0x28;

                    HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 1, 100);

                    HAL_I2C_Master_Receive(&hi2c1, HTS221R, Dat, 2, 100);

                    H_T_out = (((uint16_t)Dat[1]) << 8) | (uint16_t) Dat[0];

                   

                    // Ã�àñ÷åò

                    tmp =((uint32_t)(H_T_out - H0_T0_out)) * ((uint32_t)(H1_rh - H0_rh) * 10);

                    CHymidity = tmp / (H1_T0_out - H0_T0_out)  + H0_rh * 10;

                    if (CHymidity > 1000) CHymidity = 1000;

                    CHymidity /= 10.0;

    }

    >> 

    0690X00000603AtQAI.jpg

    0690X00000603DbQAI.jpg