This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

HDC1010: hdc1010ypar

Part Number: HDC1010

Hi,

I am trying to read temperature and humidity level from HDC1010 . For trigger and reading the sensor data, can you advise any c code ?

  • Hello Forum User

    Which MCU are you using for reading the HDC1010?
  • I am using STM32F103 MCU for reading HDC1010. I have tried code below but i could not read any data:

    I2C_GenerateSTART(I2C1, ENABLE);//start i2c
    I2C_SendData(I2C1, (uint8_t)0x40);//send slave adress, adress is 0x40 for ADDR0 and ADDR1 pins tied to GND
    I2C_SendData(I2C1, (uint8_t)0x02);// Configuration for HDC1010 14bit temperature and humidity
    I2C_SendData(I2C1, (uint8_t)0x10);//Config for MSB
    I2C_SendData(I2C1, (uint8_t)0x00);//Config for LSB
    I2C_GenerateSTART(I2C1,ENABLE);
    I2C_SendData(I2C1, (uint8_t)0x41);//send slave adress with W/R bit "1" so 0x41
    I2C_SendData(I2C1, (uint8_t)0x00);//send Temperature register address for read the value
    temp_msb = I2C_ReceiveData(I2C1);//read the msb of temperature value
    temp_lsb = I2C_ReceiveData(I2C1);//read the lsb of temperature value
    hum_msb = I2C_ReceiveData(I2C1);//read the msb of humidity value
    hum_lsb = I2C_ReceiveData(I2C1);////read the lsb of humidity value
    I2C_GenerateSTOP(I2C1,ENABLE);//stop i2c
  • Hello Forum User,

    We do not have software library for STM MCUs and am not too familiar with the STM's I2C library. However going through the sequence I would suggest the following

    I2C_GenerateSTART(I2C1, ENABLE);//start i2c
    I2C_SendData(I2C1, (uint8_t)0x40);//send slave adress, adress is 0x40 for ADDR0 and ADDR1 pins tied to GND
    I2C_SendData(I2C1, (uint8_t)0x02);// Configuration for HDC1010 14bit temperature and humidity
    I2C_SendData(I2C1, (uint8_t)0x10);//Config for MSB
    I2C_SendData(I2C1, (uint8_t)0x00);//Config for LSB
    I2C_GenerateSTOP(I2C1,ENABLE);//stop i2c

    I2C_GenerateSTART(I2C1,ENABLE);
    I2C_SendData(I2C1, (uint8_t)0x40);//send slave adress with W/R bit "0" so 0x40
    I2C_SendData(I2C1, (uint8_t)0x00);//send Temperature register address for read the value
    I2C_GenerateSTOP(I2C1,ENABLE);//stop i2c

    // WAIT FOR CONVERSION TIME

    I2C_GenerateSTART(I2C1,ENABLE);
    I2C_SendData(I2C1, (uint8_t)0x41);//send slave adress with W/R bit "1" so 0x41
    temp_msb = I2C_ReceiveData(I2C1);//read the msb of temperature value
    temp_lsb = I2C_ReceiveData(I2C1);//read the lsb of temperature value
    hum_msb = I2C_ReceiveData(I2C1);//read the msb of humidity value
    hum_lsb = I2C_ReceiveData(I2C1);////read the lsb of humidity value
    I2C_GenerateSTOP(I2C1,ENABLE);//stop i2c
  • if you have any c code library for TI MCU please send it to me , i will be able to use it for STM MCU. When i send the commands, it sends back to me the same value of "0x41" at the end of conversion of I2C_ReceiveData .
  • Hello Forum User

    The C drivers for TI MCUs are tied to the SimpleLink SDK using RTOS. I am not sure if the porting back to bare-metal drivers would work. To debug the issue you have, can you please connect a logic analyzer or scope on the SCL & SDA lines and with the function execution, see what is happening on the I2C bus. Please do post an image for each of the 3 functions so that we can see why the data is not being received correctly.

    Also do keep in mind that if the wait for conversion is not done, then the HDC1010 shall NAK the read transaction,.