ST32 HTS221 Problems
Posted: Sat Jun 11, 2022 3:39 pm
Good Morning,
I have the NCD HTS221 i2c module that I am trying to interface with the PYNQ-Z1 development board (for those who are not aware, the PYNQ-Z1 is a Xilinx board that uses MicroBlaze + Arduino header). FWIW, I have had no issues using other i2c modules so it seems to be isolated to this particular module.
Problem: I can query the device just fine (receiving DeviceID), but the temperature and humidity values never change. They are always 23.9 C and 61.5 %, respectively.
Status: I first started with my own driver code but thought I must be doing something wrong, so I fully migrated to the open-source driver found here: https://github.com/stm32duino/HTS221. When using the stm32duino driver and following their C++ / Arduino example, I still get the same result. Here is the HTS221 parts of my code:
This is my output (querying status every 1 sec):
ANy assistance fixing my code and/or troubleshooting a HTS221 device issue is much appreciated!
I have the NCD HTS221 i2c module that I am trying to interface with the PYNQ-Z1 development board (for those who are not aware, the PYNQ-Z1 is a Xilinx board that uses MicroBlaze + Arduino header). FWIW, I have had no issues using other i2c modules so it seems to be isolated to this particular module.
Problem: I can query the device just fine (receiving DeviceID), but the temperature and humidity values never change. They are always 23.9 C and 61.5 %, respectively.
Status: I first started with my own driver code but thought I must be doing something wrong, so I fully migrated to the open-source driver found here: https://github.com/stm32duino/HTS221. When using the stm32duino driver and following their C++ / Arduino example, I still get the same result. Here is the HTS221 parts of my code:
Code: Select all
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;
}
Code: Select all
[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