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.

HDC2010: Getting wrong value of temperature for the first sample alone

Part Number: HDC2010
Other Parts Discussed in Thread: SYSCONFIG

Hello All,

I am using MSP432P401R launchpad and using HDC2010 EVM kit to work on the sensor code.

I have written a code which configures 1 sample per second and even with 5 samples per second.

I am getting the data w.r.t the configurations. But the issue is with the first sample from the sensor which always gets wrong and that too for only temperature value. Humidity is getting correct.

I am  giving 1 sec delay before reading the data. Not sure what is happening with the first sample. I have iterated multiple times but same issue. Even the same issue when manually reading the data through I2C. Wondering why only Temperature data? PLease help.

I2C Initialized!            

HDC2010: HDC2010_SoftwReset executed!  

HDC2010: Sample:0                         

HDC2010: hdc20100Temp = 32 hdc20100TempAsCelsius = -39.9194             

HDC2010: hdc20100Hum = 30976 hdc20100HumAsRelative = 47.2656     

HDC2010: Test case FAIL!

                                       

HDC2010: Sample:1               

HDC2010: hdc20100Temp = 28195 hdc20100TempAsCelsius = 30.9865     

HDC2010: hdc20100Hum = 30995 hdc20100HumAsRelative = 47.2946

HDC2010: Test case PASS!

                                    

HDC2010: Sample:2                                 

HDC2010: hdc20100Temp = 28200 hdc20100TempAsCelsius = 30.9991

HDC2010: hdc20100Hum = 31008 hdc20100HumAsRelative = 47.3144

HDC2010: Test case PASS!

                         

HDC2010: Sample:3             

HDC2010: hdc20100Temp = 28199 hdc20100TempAsCelsius = 30.9966

HDC2010: hdc20100Hum = 30979 hdc20100HumAsRelative = 47.2702                        

HDC2010: Test case PASS!

                                    

HDC2010: Sample:4                   

HDC2010: hdc20100Temp = 28198 hdc20100TempAsCelsius = 30.9941        

HDC2010: hdc20100Hum = 30990 hdc20100HumAsRelative = 47.2869              

HDC2010: Test case PASS!

  • Dear Tajpeer - 

    i think the only way this could happen is if, after the very first 'start conversion' command is sent, you are not waiting long enough to read out the temperature registers 0x00 and 0x01. Because you get the %RH value back correctly, this indicates you are reading the registers 0x02 and 0x03 back separately, and after the correct amount of time has elapsed.  

    I would recommend here that you look at I2C lines, from power up, to see what the actual behavior is of your code.  

    FAQ on this topic is here: https://e2e.ti.com/support/sensors/f/1023/t/878721?tisearch=e2e-sitesearch&keymatch=HDC2010

    and FYI, this is slightly different, because the example reads out temp and humidity registers all together, but will show you what to look at. I would also recommend that you don't use the SW reset (wasted clock cycles) and also to read out the 0x04 register in your code for 0x80, (after sending the start conversion and waiting at least 1.3mSec, if using the default 14 bit resolution settings) then if that passes, to then read out the registers 0x00 through 0x03 all at once. This will guarantee you get good data, from the start, as it will force your code to wait long enough. 

     

  • Hello Wyatt,

    Thanks for the reply.

    I have tried multiple iterations. and with each iteration, I had tried with different time delays like starting from 0.5 ms till 30 ms. But it fails to get the first sample.

    I even tried first getting the Humidity value ahead of Temperature value. And it fails to get correct values for both for first sample.

    As you suggested, I even tried with DataReady status with below code. i am reading the data only when this returns 1. This returns 1 but still got the wrong value.

    /* HDC2010 IsDataReady function to check DRDY_STATUS flag */
    bool HDC2010_IsDataReady(void)
    {
    uint8_t txBuf[1];
    uint8_t rxBuf[1];
    uint8_t busId_1; /* I2C bus id */
    uint8_t devAddr_1; /* Sensor address on the I2C bus */
    bool isDataReady = 0; /* Default, data is not ready */

    /* I2C bus ID */
    busId_1 = 0;

    /* Sensor address on the I2C bus - ADR grounded*/
    devAddr_1 = HDC2010_SLAVE_ADDRESS;

    /* Write Configuration Register */
    txBuf[0] = HDC2010_INT_DRDY;
    mcu_i2cTransfer(busId_1, devAddr_1, txBuf, 1, rxBuf, 1);

    if(rxBuf[0] & 0x80)
    isDataReady = 1;

    Display_printf(display, 0, 0, "HDC2010: HDC2010_IsDataReady executed!");

    return isDataReady;
    }

  • Dear Tajpeer - 

    Please put o'scope or logic analyzer on your hardware and capture, from power up - this will show us exactly what is happening.

  • Hello Wyatt,

    I don't have oscilloscope with me now to capture the signals, due to covid-19.

    Let me trigger this thread once I get the proper signals to show and discuss.

  • OK - will wait on you then - in the meantime, would recommend you check out examples we have on sysconfig or resource explorer, as they might also help you out, in finding your timing issue, in the absence of you having the equipment to troubleshoot with. 

    I would also recommend getting a logic analyzer (which you might be able to order and receive via mail during these time) - these are infinitely helpful - i personally recommend the Saleae devices, in all my years of dealing with various protocols, this is the best one i have ever used, and I did order and receive one about a week ago, as i wanted to upgrade from their previous model, to include analog sampling ability. 

     

     

  • Till we get actual signals from logiz analyzer, I just want to show my code how I tried with different delays for getting the first sample from HCD2010 strating from 100Microseconds to 10ms.

    But with all the timing delays, we got the same results. Please suggest if you are getting anythign from the code below,

    ===============================================================

    void mcu_msWait(unsigned long msWait)
    {
    static delay = 1;
    /*
    * Add MCU specific wait loop for msWait. The unit is in milli-seconds
    */
    // Delay();
     usleep(delay*100); // In microseconds
    //usleep(msWait*1000); // ~2 ms
     delay++;
    Display_printf(display, 0, 0, "HDC2010: mcu_msWait: %d Microseconds", (delay*100));
    }

    ===============================================================

    uint32_t HDC2010_tempread(HDC2010_Handle sensor)
    {
    uint8_t txBuf[2];
    uint8_t rxBuf[1];
    uint8_t tHigh;
    uint8_t tLow;
    uint32_t tmp;

    /* If AMM is disabled trigger conversion */

    if (!(sensor->config & HDC2010_CONFIG_AMM_MASK))
    {
    /* Reset AMM to start measurement */
    txBuf[0] = HDC2010_MEAS_CONFIG;
    txBuf[1] = sensor->measConfig | HDC2010_MEAS_CONFIG_MEAS_TRIG_START;
    mcu_i2cTransfer(sensor->busId, sensor->devAddr, txBuf, 2, rxBuf, 0);

    /* Wait for conversion to complete */
    mcu_msWait(sensor->convWaitTemp);
    }

    /* Read temperature register high byte */
    txBuf[0] = HDC2010_TEMP_HIGH;
    mcu_i2cTransfer(sensor->busId, sensor->devAddr, txBuf, 1, rxBuf, 1);

    tHigh = rxBuf[0];

    /* Read temperature register low byte */
    txBuf[0] = HDC2010_TEMP_LOW;
    mcu_i2cTransfer(sensor->busId, sensor->devAddr, txBuf, 1, rxBuf, 1);= rxBuf[0];

    /* Sign extend and combine */
    tmp = ((uint32_t)tHigh << 8) | tLow;

    return (tmp);
    }

  • Dear Tajpeer - 

    the wait time you need to adjust is between you writing register 0x0F with 0x01 and reading back the results. In this case, I would recommend you do one or more of these suggestions.

    1. Implement one shot mode to reveal to yourself how the delay needs to occur between the start of conversion and reading back the registers - if in default mode, you need at least 1300mSec between issuance of 0x01 to 0x0F register and expecting new values

    Here is a flow chart for you to follow: /cfs-file/__key/communityserver-discussions-components-files/1023/ONE_5F00_SHOT_5F00_HDC20x0_5F00_FIRMWARE_5F00_FLOW.pdf

    2. Make a flow chart of your own code (since you are wanting to do automatic mode) and compare to these (this is with using DRDY/INT line and also without - two pages, two separate flow charts)

    /cfs-file/__key/communityserver-discussions-components-files/1023/AUTO_5F00_HDC20x0_5F00_FIRMWARE_5F00_FLOW.pdf

    you can also review this document, too ==> https://www.ti.com/lit/an/snaa312/snaa312.pdf