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: Part Recommendation to Read Temp & Humidity on power up

Part Number: HDC2080
Other Parts Discussed in Thread: HDC2010, ENERGIA

Hi team,

I have successfully used the HDC2080 and the HDC1080s to acquire data via Arduino I2C….with the nifty library that comes with it (HDC2010.cpp and .h).  Worked great.

However, we are looking to interface to the sensors with an PC based Aardvark Host adapter for I2C that plugs in USB.  Unfortunately the nifty library with the HDC2010 code uses the Arduino libraries under the hood and thus can’t use on the PC (that I know of).  Plus there was byte swapping on the PC that made the configuration difficult.  Now it is possible that I was doing something wrong though.

Do you have any other i2C sensors that automagically read humidity and temp automatically on power up and populate registers at around 1Hz (without having to do any config) that have a simple I2C interface to just read a couple registers?

Thank you.

  • Brad -

    No, we don't have any with an MCU or a "from POR" auto state machine.

    in this case, the issue is just with using this Aardvark tool, correct? in a real development, there would be an MCU - and this device looks to be standing in for that. IN reading the user manual, i don't see any blocking points to using the Aardvark (as the MCU) with the HDC2080. I can see that is has APIs for I2C writes and reads, which is all that is required. 

    Perhaps if you shared details of where they saw a blocking point, we can help get past that. 

    I would actually recommend that you use one shot mode, since you are not using the interrupt line - but if you really need to use AMM, then you should at least read 0x04 register before reading out the data.

    So, in this case, for AMM with no DRDY/INT usage, after power up, you would send 0x50 to 0x0E, then a 0x01 to 0x0F, then about each second, you should read 0x04 for 0x80, if 0x80, then read 0x00 through 0x03 registers.  

    Byte swapping or left shifting is just one line of c code. 

    For example, from an Energia sketch for the HDC2080 (not directly translatable, but you can see how simple it is): 

    Wire.beginTransmission(65); // transmit to HDC2080 device address 0x41 (0x82 (write), 0x83 (read))
    Wire.write(04); // pointer
    Wire.endTransmission(); // stop transmitting
    Wire.requestFrom(65, 1, 1); // request 1 bytes from HDC2080 slave device, register 0x04 (should be 0x80)
    Wire.readBytes (iBuff_INT_REG, 1);
    HDC2080_INT_REG = iBuff_INT_REG[0];
    if (HDC2080_INT_REG == 128)
    {
    Wire.beginTransmission(65); // transmit to HDC2080 device address 0x41 (0x82 (write), 0x83 (read))
    Wire.write(00); // pointer
    Wire.endTransmission(); // stop transmitting
    Wire.requestFrom(65, 4, 1); // request 4 bytes from HDC2080 slave device, registers 0x00 through 0x03
    // math here for HDC2080 output
    while (Wire.available())
    {
    Wire.readBytes(iBuff_HDC2080, 4);
    HDC2080_hum_MSB = iBuff_HDC2080[3] << 8; // shift left
    HDC2080_hum_DEC = (HDC2080_hum_MSB + iBuff_HDC2080[2]); // get value for calculation, made from iBuff index array values 3 and 2 for humidity reading.
    HDC2080_hum_percentage = ((float)(HDC2080_hum_DEC) / 65536) * 100; // do math according to the HDC2080 datasheet, page 18 www.ti.com/.../hdc2080.pdf
    Serial.print(", ");
    Serial.print(HDC2080_hum_percentage); // print out %RH to terminal
    Serial.print(" ,");
    HDC2080_temp_MSB = (iBuff_HDC2080[1] << 8); // shift left
    HDC2080_temp_DEC = (HDC2080_temp_MSB + iBuff_HDC2080[0]); // get value for calculation, made from iBuff index array values 0 and 1 for temp reading.
    HDC2080_temp_celcius = ((float)(HDC2080_temp_DEC) / 65536) * 165 - 40; // do math according to the HDC2080 datasheet, page 18 www.ti.com/.../hdc2080.pdf
    Serial.print(" ");
    Serial.println(HDC2080_temp_celcius); // print out T to terminal
    }

     

    Its no issue I think - but is there a reason for using the Aardvark vs. using MCU platform like LaunchPad? we can provide sketches that will work on all TI MCU platforms, from MSP430 G series to SimpleLink. 

  • Thanks Josh.

    I can read the devices via Arduino code (through your library) no problem but am not getting any results using the Aardvark I2C Host adapter (code below). It’s prob because I’m doing something wrong. I can see the device on startup and the open it.   However, following reads of the registers for humidity return zero. It does update the numBytesWritten/ numBytesRead.  Both bytes returned for Humidity are zero.

     

    // Open the device

    int handle = AardvarkApi.aa_open(port);

     

           // Ensure that the I2C subsystem is enabled

           AardvarkApi.aa_configure(handle, AardvarkConfig.AA_CONFIG_SPI_I2C);

     

           // Enable the I2C bus pullup resistors (2.2k resistors).

           // This command is only effective on v2.0 hardware or greater.

           // The pullup resistors on the v1.02 hardware are enabled by default.

           AardvarkApi.aa_i2c_pullup(handle, AardvarkApi.AA_I2C_PULLUP_BOTH);

     

           // Power the board using the Aardvark adapter's power supply.

           // This command is only effective on v2.0 hardware or greater.

           // The power pins on the v1.02 hardware are not enabled by default.

           AardvarkApi.aa_target_power(handle,

                                         AardvarkApi.AA_TARGET_POWER_BOTH);

     

           // Set the bitrate

           bitrate = AardvarkApi.aa_i2c_bitrate(handle, I2C_BITRATE);

           Console.WriteLine("Bitrate set to {0} kHz", bitrate);

     

           byte HUMID_LOW = 0x02;

           byte HUMID_HIGH = 0x03;

     

           // Point to the HUMID_LOW

           data_out[0] = HUMID_LOW;

           res = AardvarkApi.aa_i2c_write_read(handle, sensorAddress, AardvarkI2cFlags.AA_I2C_NO_FLAGS, 1, data_out, ref numBytesWritten, 1, data_in, ref numBytesRead);

     

           // Point to the HUMID_HIGH

           data_out[0] = HUMID_HIGH;

           res = AardvarkApi.aa_i2c_write_read(handle, sensorAddress, AardvarkI2cFlags.AA_I2C_NO_FLAGS, 1, data_out, ref numBytesWritten, 1, data_in, ref numBytesRead);

     

     

     

  • Dear Jim - 

    in the future, please use the "+ Ask a related question button" in the case you want to ask a question which is related to an existing thread. 

    in your case, I don't see a start conversion command (this would be issuing a 0x01 to register 0x0F), then waiting for >1300uSec, then reading out Register 0x04 for 0x80, before proceeding to read out registers 0x00 through 0x03 (or just 0x02 and 0x03, your choice there)

    Also, I would consider looking at what happens on the I2C bus (with a scope or logic analyzer) when you use the  'aa_i2c_write_read' API and compare to using the individual available write (for pointer) and then read (for data) APIs - just a thought as I don't have one of these Aardvarks in hand, but I did read a bit in the user manual for it.