Animok
Joined: 03 May 2018 Posts: 11
|
HDC1000 WORKING |
Posted: Mon Feb 25, 2019 12:05 pm |
|
|
Hello everyone!
I got many solutions from this forum, so I would like contribute with my solution about HDC1000 sensor.
I read temperature and humidity separately. Here you are the routines:
Code: |
#use i2c(Master,SLOW,sda=PIN_B5,scl=PIN_B4,force_hw)
//------
void hdc_setup(void)
{
i2c_start();
i2c_write(0x02);
i2c_write(0x20); //
i2c_write(0x00);
i2c_stop();
delay_ms(500);
}
//********************************************************
void read_T(void)
{
i2c_start();
i2c_write(0x80);
i2c_write(0x00);
delay_ms(300); //that's the key!!
i2c_write(0x81);
data[0]=i2c_read();
data[1]=i2c_read(0);
i2c_stop();
variaL=make16(data[0],data[1]);
temperature=(variaL*0.0025177)-40;
delay_ms(500);
}
//*********************************************************
void read_HR(void)
{
i2c_start();
i2c_write(0x80);
i2c_write(0x01);
delay_ms(300); //that's the key!!
i2c_write(0x81);
data[0]=i2c_read();
data[1]=i2c_read(0);
i2c_stop();
variaL=make16(data[0],data[1]);
humidity=(variaL*0.0015258);
delay_ms(500);
}
|
This is for all good people in the world! |
|