Skip to main content
Visitor II
January 25, 2020
Question

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.

  • January 25, 2020
  • 3 replies
  • 1109 views

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

    This topic has been closed for replies.

    3 replies

    Visitor II
    January 25, 2020

    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.2Author
    Visitor II
    January 28, 2020

    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.2Author
    Visitor II
    January 31, 2020

    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.