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.

HDC1080: Sample Reading, and firmware

Part Number: HDC1080
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

 

  • Hi Josh,

    It seems i read the correct values and then i am reading 0x83,0x83,0x83,0x83.

  • Dear Dharmesh - 

    here you have set the part for AMM mode for once a second, yet you send one shot each minute. this means that you set the part to AMM mode, but then did not trigger it first time until the delay time passed. At which point you wait 5mSec (i think 500 x 100uSec is 5mSec then read out the part. Maybe just write 0x00 to 0x0E after power up (or not at all) and waiting at least 3mSec after power up, then starting I2C, writing the register, start a conversion right then and read back ~ 1.3mSec later, then you can start reading 0x04 for 0x080 every time interval for when data is ready, as if you intend to read out registers 0x00 through 0x03 each minute, then you should either change the measurement mode to doing one shots each minute or set the 0x0E register to 0x02 and just read out the registers, using 0x04 as trigger or also using DRDY/INT pin, as now you have conflict between setting for AMM and sending the one shots.

       

  • Hi Dharmesh,

    Thank you for your post. I don't see any obvious issues in your code.

    Can you capture one of the bad readings via Logic Analyzer or Oscilloscope? That would tell us whether this is a software or hardware issue. 

    Best Regards,
    Brandon Fisher

  • Dear Josh and Brandon

     I have manged to get it working, but not sending ACK on my last read. I will keep it running over night and see the logs tomorrow.

         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,0);
            twiStop(TWI);     

    I have now set the reg 0E to 0, so that when i need to read the sample, my application can execute an sample.

       twiInitialize(TWI);
        twiAddress(TWI,HUM_ADDR_HDC2080_NO2_PCB,0);
        twiWriteSingle(TWI,0x0E);
        twiWriteSingle(TWI,0x00);
        twiStop(TWI)

    Regards

  • Thanks Dharmesh,

    Please let us know the results when you have them. 

    Best Regards,
    Brandon Fisher