Skip to content

Temperature and Humidity

Thermometer: EXT4_Weather

I2C address is 0x40

The demo starts with a WhoAmI check that should return 0x33.

Then, initializes the sensor with the following configuration:

StepRegisterValue
10x0e RESET&DRDY/INT CONF0x00 Soft Reset and Interrupt Configuration
20x0f MEASUREMENT CONFIGURATION0xfe

The main loop follows with the following sequence:

StepRegisterValue
Write0x0f MEASUREMENT CONFIGURATION0xff Start measurement

Temperature measurement

Read 2 bytes starting from 0x00 TEMPERATURE_LOW register. Scale the result with a factor of 165.0 / 65536.0 - 40.0.

Humidity measurement

Read 2 bytes starting from 0x02 HUMIDITY_LOW register. Scale the result with a factor of

1 / 65536.0 * 100.0.

The rest of the code is for displaying the results on the EPD screen.


// HDC2080
#include "Wire.h"

#define HDC_I2C 0x40

uint8_t bufferWrite[8] = { 0 };
uint8_t bufferRead[8] = { 0 };

measure_s temperature;
measure_s humidity;

void setup()
{
    // HDC2080
    hV_HAL_Wire_begin();

    bufferWrite[0] = 0x0e; // HDC20X0_CONFIGURATION
    bufferWrite[1] = 0x00; // HDC20X0_DEFAULT_SETTINGS
    hV_HAL_Wire_transfer(HDC_I2C, bufferWrite, 2, bufferRead, 0);

    bufferWrite[0] = 0x0f; // HDC20X0_MEASURE_CONFIGURATION
    bufferWrite[1] = 0xfe; // HDC20X0_MEASURE_SETTINGS
    hV_HAL_Wire_transfer(HDC_I2C, bufferWrite, 2, bufferRead, 0);
}

void loop()
{
    if (millis() > chrono32)
    {
        // HDC2080
        bufferWrite[0] = 0x0f; // HDC20X0_MEASURE_CONFIGURATION
        bufferWrite[1] = 0xff; // HDC20X0_DEFAULT_SETTINGS
        hV_HAL_Wire_transfer(HDC_I2C, bufferWrite, 2, bufferRead, 0);
        delay(50);

        // Temperature
        bufferWrite[0] = 0x00; // HDC20X0_TEMPERATURE_LOW
        hV_HAL_Wire_transfer(HDC_I2C, bufferWrite, 1, bufferRead, 2);
        temperature.value = bufferRead[0] + bufferRead[1] * 256.0;
        temperature.value = temperature.value * 165.0 / 65536.0 - 40.0; // +273.15; // from °C to °K

        // Humidity
        bufferWrite[0] = 0x02; // HDC20X0_HUMIDITY_LOW
        hV_HAL_Wire_transfer(HDC_I2C, bufferWrite, 1, bufferRead, 2);
        humidity.value = bufferRead[0] + bufferRead[1] * 256.0;
        humidity.value = humidity.value / 65536.0 * 100.0;
    }
}

The full demo can be found here: https://github.com/PervasiveDisplays/PDLS_EXT4_Basic_Matter/tree/main/examples/EXT4