cancel
Showing results for 
Search instead for 
Did you mean: 

I have a X-NUCLEO-IKS01A2 board connected to a stm32 nucleo and I'm trying to read the temperature from the HTS221. However, I get really wrong values. Does something need to be set in the control registers before reading? Thanks.

JMora.2
Associate II

I am using the code provided in the TN1218 sheet, and I've attached a screenshot of my variables.

3 REPLIES 3
S.Ma
Principal

As far as I recall, first you need to read calibration data from the sensor, then read the raw temperature and apply the formulas.

There is a github standard C drivers for most ST sensors, you could start from there.

JMora.2
Associate II

Hello. I am using the code ST provided which includes reading the calibration registers. I'm pretty sure there is something wrong with the way I am transmitting the data. Below is my code fore reference:

int hts_read_reg(I2C_HandleTypeDef *_i2chandle, uint8_t _reg, uint8_t *_buff, uint8_t _size)

{

if(HAL_I2C_Master_Transmit(_i2chandle, HTS_WR_ADDR, &_reg, 1, TIMEOUT) != HAL_OK)

return -1;

if(HAL_I2C_Master_Receive(_i2chandle, HTS_RD_ADDR, _buff, _size, TIMEOUT) != HAL_OK)

return -1;

return 0;

}

JMora.2
Associate II

To add a bit more clarity to my question - Sometimes my T_OUT value doesn't update at all, and other times it updates but produces very sporadic values. Since I am using the code provided in TN1218, I am unsure how to proceed. I've also tried using a couple of people's implementations for retrieving temperature but I still get wild results.

Thanks.