Skip to main content
Visitor II
June 15, 2022
Question

Unable to initialize/activate HTS221

  • June 15, 2022
  • 2 replies
  • 963 views

Good Afternoon.

I have an NCD module that uses the HTS221 sensor. I have posted this question on their support forum as well, but they were not able to help me. Likewise, I have posted this question on the STM32duino support forum as well, since I am using their API to configure the HTS221 sensor.

I am, from what I can tell, able to communicate with the HTS221 -- I can successfully poll the sensor for its device ID (0xBC) and the configuration register without errors. However, when I try to update the configuration (set ODR to 1 hz) and activate the sensor (set PD bit to 1) nothing happens. The configuration does not appear to change and polling the temp/humidity gives me the same results every time. Here is an example of what is output (at 1 hz):

[17:30:46] Humidity: 61.5, Temp_C: 23.9, Temp_F: 75.02, DevId: 0xbc, Error: 0x0
[17:30:47] Humidity: 61.5, Temp_C: 23.9, Temp_F: 75.02, DevId: 0xbc, Error: 0x0
[17:30:48] Humidity: 61.5, Temp_C: 23.9, Temp_F: 75.02, DevId: 0xbc, Error: 0x0
[17:30:49] Humidity: 61.5, Temp_C: 23.9, Temp_F: 75.02, DevId: 0xbc, Error: 0x0
[17:30:50] Humidity: 61.5, Temp_C: 23.9, Temp_F: 75.02, DevId: 0xbc, Error: 0x0
[17:30:51] Humidity: 61.5, Temp_C: 23.9, Temp_F: 75.02, DevId: 0xbc, Error: 0x0
[17:30:52] Humidity: 61.5, Temp_C: 23.9, Temp_F: 75.02, DevId: 0xbc, Error: 0x0
[17:30:53] Humidity: 61.5, Temp_C: 23.9, Temp_F: 75.02, DevId: 0xbc, Error: 0x0
[17:30:54] Humidity: 61.5, Temp_C: 23.9, Temp_F: 75.02, DevId: 0xbc, Error: 0x0
[17:30:55] Humidity: 61.5, Temp_C: 23.9, Temp_F: 75.02, DevId: 0xbc, Error: 0x0

Here is the code that I am using, specific to this sensor:

i2c device_hts;
SensorRing_st ring = {0}; 
HTS_Data_st hts_data = {0};
...
// initialize the sensor
ring.error |= HTS_Begin(&device_hts,&hts_data);
// collect data
while(1) {
	ring.error |= HTS_Poll(&device_hts,&hts_data);
	dealy_us(4000); // delay 4msec (I've tried 1 second delays, same result)
}
 
SensorRing_Error_et HTS_Begin(void *handle, HTS_Data_st *hts_data)
{ 
 /* Power down the device */
 if ( HTS_DeActivate( (void *)handle ) == HTS_ERROR )
 return HTS_SENSOR_ERROR;
 
 /* Enable BDU */
 if ( HTS_Set_BduMode( (void *)handle, HTS_ENABLE ) == HTS_ERROR )
 {
 return HTS_SENSOR_ERROR;
 }
 if (HTS_Set_Odr((void *)handle, HTS_ODR_1HZ) == HTS_ERROR)
 {
 return HTS_SENSOR_ERROR;
 }
 // I also tried just using the Set_InitConfig() method, same result
 // HTS_Init_st hts_init = {0};
 // hts_init.avg_h = HTS_AVGH_4;
 // hts_init.avg_t = HTS_AVGT_2;
 // hts_init.odr = HTS_ODR_1HZ;
 // hts_init.bdu_status = HTS_DISABLE;
 // hts_init.heater_status = HTS_DISABLE;
 // hts_init.irq_level = HTS_HIGH_LVL;
 // hts_init.irq_output_type = HTS_PUSHPULL;
 // hts_init.irq_enable = HTS_DISABLE;
 // HTS_Set_InitConfig((void *)handle,&hts_init);
 
 /* Enable sensor */
 HTS_Activate((void *)handle);
 
 /* Tag sensor */
 HTS_Get_DeviceID((void *)handle,&hts_data->id);
 
 return ALL_SENSOR_OK;
}

I am using the ST32 HTS221 library found here: github.com/stm32duino/HTS221

    This topic has been closed for replies.

    2 replies

    ST Employee
    June 17, 2022

    Hi @christnp​ ,

    so you can receive data but they are always stuck at the same value?

    Can you please check the STATUS_REG (27h) T_DA and H_DA bits?

    And are you facing this issue also on other HTS221?

    -Eleon

    christnpAuthor
    Visitor II
    June 17, 2022

    @Eleon BORLINI​ ,

    Thank you for responding, I appreciate your help!

    Yes, you are correct. I receive data but the values never change. And it appears that the T_DA and H_DA bits are both zero (0) in all cases as well. Here is an updated view with the data ready bits included:

    [18:03:06] Humidity Rdy: 0, Humidity: 55.9, Temp Rdy: 0, Temp_C: 24.8, Temp_F: 76.64, DevId: 0xbc, Error: 0x0
    [18:03:07] Humidity Rdy: 0, Humidity: 55.9, Temp Rdy: 0, Temp_C: 24.8, Temp_F: 76.64, DevId: 0xbc, Error: 0x0
    [18:03:08] Humidity Rdy: 0, Humidity: 55.9, Temp Rdy: 0, Temp_C: 24.8, Temp_F: 76.64, DevId: 0xbc, Error: 0x0
    [18:03:09] Humidity Rdy: 0, Humidity: 55.9, Temp Rdy: 0, Temp_C: 24.8, Temp_F: 76.64, DevId: 0xbc, Error: 0x0
    [18:03:10] Humidity Rdy: 0, Humidity: 55.9, Temp Rdy: 0, Temp_C: 24.8, Temp_F: 76.64, DevId: 0xbc, Error: 0x0
    [18:03:11] Humidity Rdy: 0, Humidity: 55.9, Temp Rdy: 0, Temp_C: 24.8, Temp_F: 76.64, DevId: 0xbc, Error: 0x0
    [18:03:12] Humidity Rdy: 0, Humidity: 55.9, Temp Rdy: 0, Temp_C: 24.8, Temp_F: 76.64, DevId: 0xbc, Error: 0x0
    [18:03:13] Humidity Rdy: 0, Humidity: 55.9, Temp Rdy: 0, Temp_C: 24.8, Temp_F: 76.64, DevId: 0xbc, Error: 0x0
    [18:03:14] Humidity Rdy: 0, Humidity: 55.9, Temp Rdy: 0, Temp_C: 24.8, Temp_F: 76.64, DevId: 0xbc, Error: 0x0
    [18:03:15] Humidity Rdy: 0, Humidity: 55.9, Temp Rdy: 0, Temp_C: 24.8, Temp_F: 76.64, DevId: 0xbc, Error: 0x0

    Unfortunately, I have only one HTS221 module at the moment.

    Any other tests I can perform? Or other data you'd like to see?

    R/

    Nick