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 i2c communication

Other Parts Discussed in Thread: HDC1010

Hello,

I'm using TI HDC1010 Temperature and Humidity sensor interfaced with I2C.

My code is running on NIOS .

I'm able to read the manufacturing ID , serial number of the product but not getting temp and humidity values.

According to sensor data sheet it has to be configured first , I tried to do that but i have a doubt on it.

Configuration and reading code:

1. first method

I2C_start(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x43 ,0x00);
I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x02 , 0x00);

I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x04 , 0x00);
I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x00 , 0x01);

I2C_start(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x43 ,0x00);
I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x00 , 0x00);
I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x00 , 0x01);

I2C_start(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x43 ,0x00);
I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x00 , 0x00);
I2C_start(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x43 ,0x01);


usleep(20000);
data = I2C_read(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x00);
data = ((data << 8) | (I2C_read(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x01)));

slave addr = 0x43;

here third argument (0x00/0x01) represents ACK/NOACK

2. Second Method

 I2C_start(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x43 ,0x00);

I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x02 , 0x00);
I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x04 , 0x00);
I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x00 , 0x00);

I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x00 , 0x00);
I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x00 , 0x01);

I2C_start(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x43 ,0x00);
I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x00 , 0x00);
I2C_start(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x43 ,0x01);

usleep(20000);
data = I2C_read(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x00);
data = ((data << 8) | (I2C_read(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x01)));

I have attached datasheet of sensor...

Anyone who worked with this sensor plz share some demo code ..

Thanks and Regards

Ankur

hdc1010.pdf

  • Hello Ankur,
    I have moved your question to the appropriate forum.
    -Francis Houde
  • Hi Ankur,

    The following is the correct procedure to read the temperature or humidity data from the output registers using the I2C interface:

    1) point the output register you want to read in order to trigger the start of the measurement:

    Start | Slave Address + W | ACK | Address | ACK | STOP

    2) wait the conversion time (in case of T + RH at highest resolution the conversion time is 15msec typical and 20msec max)

    3) read the output data:

    Start | Slave Address + R | ACK | Data | ACK | Data | NACK | STOP

    Please note that any I2C write addressing the output registers (RH or T) triggers the start of a new conversion.

    In your code you probably have to do:

    // Configure the device

    I2C_start(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x43 ,0x00);
    I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x02 , 0x00);

    I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x04 , 0x00);
    I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x00 , 0x01);

    // point the output register you want to read in order to trigger the start of the measurement:

    I2C_start(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x43 ,0x00);
    I2C_write(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x00 , 0x00);

    // wait the conversion time
    usleep(20000);

    // read the output data:

    I2C_start(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x43 ,0x00);
    data = I2C_read(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x00);
    data = ((data << 8) | (I2C_read(OC_I2C_MASTER_TEMP_HUMDITY_BASE , 0x01)));

    Please let me know if this works.

    Best regards,

    Carmine