Other Parts Discussed in Thread: HDC2080
Dear Josh
This is in connection to my previous post, in regards to HDC2080.
I have now added the component assembled into our board, and trying to get the firmware working.
I am not sure what i am doing wrong, as the first sample looks correct, then 2nd samples increases its values, then 3rd goes back to normal . It keep alternating.
This is my code structure.
This the very first step on initialising.
void read_humdidity_temperture_setup_HDC2080(void) { twiInitialize(TWI); twiAddress(TWI,HUM_ADDR_HDC2080_NO2_PCB,0); twiWriteSingle(TWI,0x0E); twiWriteSingle(TWI,0x50); twiStop(TWI); twiInitialize(TWI); twiAddress(TWI,HUM_ADDR_HDC2080_NO2_PCB,0); twiWriteSingle(TWI,0x0F); twiWriteSingle(TWI,0x00); twiStop(TWI); }
Then i am doing this once a min.
temphumditysensor_t read_humdidity_temperture_HDC2080(void) { temphumditysensor_t sensor_output; twiInitialize(TWI); twiAddress(TWI,HUM_ADDR_HDC2080_NO2_PCB,0); twiWriteSingle(TWI,0x0F); twiWriteSingle(TWI,0x01); twiStop(TWI); for (uint16_t x=0;x<500;x++) { HAL_Delay(100); //100 us } twiInitialize(TWI); twiAddress(TWI,HUM_ADDR_HDC2080_NO2_PCB,0); twiWriteSingle(TWI,0x00); twiStop(TWI); for (uint16_t x=0;x<500;x++) { HAL_Delay(100);//100us } twiInitialize(TWI); twiAddress(TWI,HUM_ADDR_HDC2080_NO2_PCB,1); sensor_reading[3] = twiReadSingle(TWI,1); sensor_reading[2] = twiReadSingle(TWI,1); sensor_reading[1] = twiReadSingle(TWI,1); sensor_reading[0] = twiReadSingle(TWI,1); twiStop(TWI); temperture_reading = (sensor_reading[2] <<8) | sensor_reading[3]; humdidty_reading = (sensor_reading[0] <<8) | sensor_reading[1]; temp_float= (((float)temperture_reading/65536)*165)-40; humd_float = ((float)humdidty_reading/65536)*100; sensor_output.temperture=temperture_reading; sensor_output.humidity=humdidty_reading; return sensor_output; }
Please advice what i am doing wrong?
Thanks