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.

HDC2080: Not getting correct temperature values when connected to cc2538

Part Number: HDC2080
Other Parts Discussed in Thread: Z-STACK, CC2538, OPT3001

Hello,

My HDC2080 sensor is not giving correct temperature values when connected to cc2538 with Z-Stack environment.
The temperature values are fluctuating and not correct either.

Below is my initialization, i have referred the HDC2082 application note snaa312.pdf.

My i2c bus is communicating properly with other sensors. HDC2080 Configured for single Acquisition configuration

#define HDC2080_ADDRESS                     0x82  //As my address pin is connected to VDD.

uint8 opt_buf_start[2]={0x0E,0x00}; uint8 opt_buf1_start[2]={0x0F,0x00};

void HDC_Init(void){

  HalI2CSendMultiple(HDC2080_ADDRESS, opt_buf_start, 2);
  HalI2CSendMultiple(HDC2080_ADDRESS, opt_buf1_start, 2);
}



uint8 addr1 = 0x00; uint16 total,degree;
uint8 opt_buf[2]={0x0F, 0x01}; uint8 temp_hu[4];

void HDC2080_Testing(void)
{
/*********    HDC SENSOR TESTING    ****************/
  HalI2CSendMultiple(HDC2080_ADDRESS, opt_buf, 2);

HDC_WaitUs(2000); //2 msec delay as per application sheet HalI2CSend(HDC2080_ADDRESS, &addr1, 1); HalI2CReceiveMultiple(HDC2080_ADDRESS, temp_hu, 4); total =(temp_hu[1] <<8) + temp_hu[0]; degree = ((total)/pow(2,16))*165-40; }


Please correct if my initialization process is wrong or something missing.

Thank you

Regards,
Akshay
  • Hello Akshay,

    When configuring the HDC2080 for beginning measurement the configuration register must be set as 0x01 to start the measurement and then after 2 ms the data should be read back.

    Also when reading the data back can you check the raw value of the temp_hu variable?

    Lastly by what value is the temp fluctuating?
  • Hello Amit,

    I was following the same procedure as you mentioned but didn't got correct values and the values are fluctuating drastically.

    Yes i am reading the raw values for temp_hu , where temp_hu [0] is Low value and temp_hu [1] is high value for temperature. I can observe that the high value is changing for every reading and the Low value remains stable.

    As per application manual for HDC2080 total =(temp_hu[1] <<8) + temp_hu[0]; this line is correct to convert temp raw value to 16 bit.

    So what can be the reason i am not able to get correct output ?

    I guess that it might be caused due to high value for temperature is changing & Low value is stable, though it should be vice versa.
  • Hello Akshay,

    When reading the data, the values are read out LSB first. Hence the temp_hu[0] should be the lower byte and temp_hu[1] should be the higher byte. However there could be something being done in the SW layer that my be swapping the values. To double check that, I would suggest hooking up a Scope or LA to the I2C bus and putting a break point on the read function. Then step over the function and capture the data on scope/LA and read the variables to compare the value that you see on the scope v/s the variable to see how SW manipulates the data (if any). Do please put the scope snapshot as well in your response.
  • Hello Akshay,

    Is there an update from your side regarding the same?
  • Hello Amit,

    Sorry for for late response,.

    I tried but getting same result, attach are output for logic analyzer for your reference.

    I have done initialization as per application note For A Single Acquisition Configuration.

    In one logic analyzer picture you can see i am writing 0x01 to register 0x0F

    In second logic analyzer picture you can see i am writing register address 0x00 & reading temperature low & high value and also humidity low & high value consecutively.

    Please let me know where i am going wrong and Also let me know what i2c clock  frequency should i prefer to run HDC2080 ?

     .

  • Hello Akshay,

    A correction here. The data transmission from the HDC2080 is MSB first as per the datasheet. However also when reading the data, the transaction should be
    START-SA_W-REG_ADDR-START-SA_R-DATA0-DATA1-DATA2-DATA3-STOP

    However looking at the sequence above it is

    START-SA_W-REG_ADDR-STOP and START-SA_R-DATA0-DATA1-DATA2-DATA3-STOP

    This may be causing a register address increment to happen. In the meantime I will check my EVM to see what happens for a room temp of ~23 C and Room Humidity of ~35% RH
  • Hello Amit,

    I will try your suggestion, Though i was referring attached flow chart given in application note assuming that it is correct procedure.

    Thank you

  • Hello Akshay,

    For a room temp of ~21C and ~25% RH I see the following

    The Temp raw value in hex is to be read as 0x5F8D and %RH raw value to be read as 0x41F1. Please do note the repeated start at the end of the write frame instead of a Stop.

  • Hello Amit,

    I tried your suggestion and it works for me.

    Now another problem i am facing is when i connect HDC2080 & OPT3001 senosr on same i2c bus with different address. I am not getting proper values for HDC humidity and opt sensor when i call read function for OPT and HDC in sequence.

    Though if i call any one function for read(hdc or opt) its working, can you suggest what can be the issue.

    Thank you

    Regards,
    Akshay bansod
  • Hello Akshay,

    Check the bus to see what is happening. I would also suggest posting it to the respective MCU forum as it sounds to be a SW issue than a device issue.

    Lastly do make sure that the Slave Address are not the same.
  • Hello Amit,

    Thank you,

    I am able to see proper data transmitted for both sensors on logic analyzer, but still not getting proper output.

    Only temperature is correct.

    Regards,
    Akshay Bansod

  • Hello Akshay,

    Please check the SW if the correct transactions are being done.