HDC2021¶
A driver for the Texas Instruments HDC2021 temperature and humidity sensor.
Only the basic functionality is needed - to start the sensor in one-shot mode and collect a temperature and humidity measurement.
It is compatible with the HDC2022 and HDC2080 parts, which are electrically identical.
Defines
-
TEMPL_REGADDR¶
Temperature Low register address.
-
TEMPH_REGADDR¶
Temperature High register address.
-
HUML_REGADDR¶
Humidity Low register address.
-
HUMH_REGADDR¶
Humidity High register address.
-
STAT_REGADDR¶
Status register address.
-
INTEN_REGADDR¶
Interrupt enable register address.
-
TEMPOFFSETADJ_REGADDR¶
Temperature offset adjustment register address.
-
HUMOFFSETADJ_REGADDR¶
Humidity offset adjustment register address.
-
DEVCONF_REGADDR¶
Device configuration (soft-reset and interrupt reporting) register address.
-
MEASCONF_REGADDR¶
Measurement configuration register address.
-
MANFIDL_REGADDR¶
Manufacturer ID low-byte address.
-
MANFIDH_REGADDR¶
Manufacturer ID high-byte address.
-
DEVIDL_REGADDR¶
Device ID low-byte address.
-
DEVIDH_REGADDR¶
Device ID high-byte address.
-
MEASCONF_MEAS_TRIG_BIT¶
Trigger a measurement when applied to MEASCONF_REGADDR
-
STAT_DRDY_STATUS_BIT¶
Select the DRDY_STATUS bit from STAT_REGADDR
-
INTEN_DRDYEN_BIT¶
Enable the DataReady Interrupt when applied to INTEN_REGADDR
-
DEVCONF_SOFT_RES_BIT¶
Trigger a soft reset when applied to DEVCONF_REGADDR
-
DEVCONF_DRDY_INTEN_BIT¶
Enable the DRDY/INTEN pin when applied to DEVCONF_REGADDR
Functions
-
int hdc2021_startconv()¶
Trigger a one-shot conversion.
The HDC2021 is in one-shot mode. This function sends an I2C command to trigger the temperature and humidity measurement.
It also configures the interrupt pin on HDC2021 to make a high-to-low transition when the conversion data are ready. This takes ~500us, so the MSP430 can sleep in this time to save power.
-
int hdc2021_init()¶
Initialise the HDC2021 in one-shot mode.
-
uint32_t hdc2021_read_temprh(int *temp12b, int *rh12b)¶
Read temperature and humidity from the HDC2021.
- Parameters
temp12b – [out] Pointer to a variable for storing the raw 12-bit temperature.
rh12b – [out] Pointer to a variable for storing the raw 12-bit relative humidity.
-
int hdc2021_read_whoami()¶
Read the Device ID registers.
- Returns
A 16-bit Device ID. The expected value is 0x07D0.