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