Data Logger BLE Cellular Board
Loading...
Searching...
No Matches
HDC2080.h File Reference
#include <stdint.h>
#include <stdio.h>

Go to the source code of this file.

Macros

#define FOURTEEN_BIT   0
 
#define ELEVEN_BIT   1
 
#define NINE_BIT   2
 
#define TEMP_AND_HUMID   0
 
#define TEMP_ONLY   1
 
#define HUMID_ONLY   2
 
#define ACTIVE_LOW   0
 
#define ACTIVE_HIGH   1
 
#define LEVEL_MODE   0
 
#define COMPARATOR_MODE   1
 
#define MANUAL   0
 
#define TWO_MINS   1
 
#define ONE_MINS   2
 
#define TEN_SECONDS   3
 
#define FIVE_SECONDS   4
 
#define ONE_HZ   5
 
#define TWO_HZ   6
 
#define FIVE_HZ   7
 
#define HDC_ADDRESS   0x40
 
#define MAN_ID   0x5449
 
#define DEV_ID   0x07D0
 
#define DRDY_STATUS   0x80
 
#define TH_STATUS   0x40
 
#define TL_STATUS   0x20
 
#define HH_STATUS   0x10
 
#define HL_STATUS   0x08
 
#define TH_ENABLE   0x40
 
#define TL_ENABLE   0x20
 
#define HH_ENABLE   0x10
 
#define HL_ENABLE   0x08
 
#define TEMP_LOW   0x00
 
#define TEMP_HIGH   0x01
 
#define HUMID_LOW   0x02
 
#define HUMID_HIGH   0x03
 
#define INTERRUPT_DRDY   0x04
 
#define TEMP_MAX   0x05
 
#define HUMID_MAX   0x06
 
#define INTERRUPT_CONFIG   0x07
 
#define TEMP_OFFSET_ADJUST   0x08
 
#define HUM_OFFSET_ADJUST   0x09
 
#define TEMP_THR_L   0x0A
 
#define TEMP_THR_H   0x0B
 
#define HUMID_THR_L   0x0C
 
#define HUMID_THR_H   0x0D
 
#define HDC_CONFIG   0x0E
 
#define MEASUREMENT_CONFIG   0x0F
 
#define MID_L   0xFC
 
#define MID_H   0xFD
 
#define DEVICE_ID_L   0xFE
 
#define DEVICE_ID_H   0xFF
 

Functions

int initHDC2080 (void)
 Initializes the HDC2080 sensor with default parameters.
 
float readTemp (void)
 Reads the temperature data from the HDC2080 sensor.
 
uint8_t readTempOffsetAdjust (void)
 Reads the temperature offset adjustment value.
 
uint8_t setTempOffsetAdjust (uint8_t)
 Sets the temperature offset adjustment value.
 
float readHumidity (void)
 Reads the relative humidity from the HDC2080 sensor.
 
uint8_t readHumidityOffsetAdjust (void)
 Reads the humidity offset adjustment value from the sensor.
 
uint8_t setHumidityOffsetAdjust (uint8_t)
 Sets the humidity offset adjustment value.
 
void enableHeater (void)
 Enables the internal heating element of the HDC2080.
 
void disableHeater (void)
 Disables the internal heating element of the HDC2080.
 
void setLowTemp (float temp)
 Sets the low temperature threshold for the interrupt pin.
 
void setHighTemp (float temp)
 Sets the high temperature threshold for the interrupt pin.
 
void setHighHumidity (float humid)
 Sets the high humidity threshold for the interrupt pin.
 
void setLowHumidity (float humid)
 Sets the low humidity threshold for the interrupt pin.
 
float readLowHumidityThreshold (void)
 Reads the low humidity threshold currently set in the sensor.
 
float readHighHumidityThreshold (void)
 Reads the high humidity threshold currently set in the sensor.
 
float readLowTempThreshold (void)
 Reads the low temperature threshold currently set in the sensor.
 
float readHighTempThreshold (void)
 Reads the high temperature threshold currently set in the sensor.
 
void triggerMeasurement (void)
 Manually triggers a single measurement cycle.
 
void reset (void)
 Performs a software reset on the HDC2080.
 
void enableInterrupt (void)
 Enables the physical interrupt/DRDY pin.
 
void disableInterrupt (void)
 Disables the physical interrupt/DRDY pin (sets to High-Z).
 
uint8_t readInterruptStatus (void)
 Reads the interrupt status register.
 
void clearMaxTemp (void)
 Resets the Maximum Temperature peak-hold register to 0.
 
void clearMaxHumidity (void)
 Resets the Maximum Humidity peak-hold register to 0.
 
float readMaxTemp (void)
 Reads the highest temperature recorded since the last clear.
 
float readMaxHumidity (void)
 Reads the maximum humidity recorded since the last clear.
 
void enableThresholdInterrupt (void)
 Enables the high/low temperature and humidity threshold interrupts.
 
void disableThresholdInterrupt (void)
 Disables the high/low temperature and humidity threshold interrupts.
 
void enableDRDYInterrupt (void)
 Enables the Data Ready (DRDY) interrupt.
 
void disableDRDYInterrupt (void)
 Disables the Data Ready (DRDY) interrupt.
 
void setTempRes (int resolution)
 Sets the temperature measurement resolution.
 
void setHumidRes (int resolution)
 Sets the humidity measurement resolution.
 
void setMeasurementMode (int mode)
 Configures whether the sensor measures Temp, Humidity, or both.
 
void setRate (int rate)
 Sets the automatic measurement frequency.
 
void setInterruptPolarity (int polarity)
 Configures the electrical behavior of the INT pin when active.
 
void setInterruptMode (int polarity)
 Sets the interrupt pin to either level-sensitive or comparator mode.
 
uint8_t readReg (uint8_t reg, uint8_t *data, uint8_t count)
 Reads a specified number of bytes from a sensor register over I2C.
 
uint8_t writeReg (uint8_t reg, uint8_t *data, uint8_t count)
 Writes a specified number of bytes to a sensor register over I2C.
 

Macro Definition Documentation

◆ ACTIVE_HIGH

#define ACTIVE_HIGH   1

Definition at line 25 of file HDC2080.h.

◆ ACTIVE_LOW

#define ACTIVE_LOW   0

Definition at line 24 of file HDC2080.h.

◆ COMPARATOR_MODE

#define COMPARATOR_MODE   1

Definition at line 27 of file HDC2080.h.

◆ DEV_ID

#define DEV_ID   0x07D0

Definition at line 41 of file HDC2080.h.

◆ DEVICE_ID_H

#define DEVICE_ID_H   0xFF

Definition at line 72 of file HDC2080.h.

◆ DEVICE_ID_L

#define DEVICE_ID_L   0xFE

Definition at line 71 of file HDC2080.h.

◆ DRDY_STATUS

#define DRDY_STATUS   0x80

Definition at line 42 of file HDC2080.h.

◆ ELEVEN_BIT

#define ELEVEN_BIT   1

Definition at line 17 of file HDC2080.h.

◆ FIVE_HZ

#define FIVE_HZ   7

Definition at line 37 of file HDC2080.h.

◆ FIVE_SECONDS

#define FIVE_SECONDS   4

Definition at line 34 of file HDC2080.h.

◆ FOURTEEN_BIT

#define FOURTEEN_BIT   0

Definition at line 16 of file HDC2080.h.

◆ HDC_ADDRESS

#define HDC_ADDRESS   0x40

Definition at line 38 of file HDC2080.h.

◆ HDC_CONFIG

#define HDC_CONFIG   0x0E

Definition at line 67 of file HDC2080.h.

◆ HH_ENABLE

#define HH_ENABLE   0x10

Definition at line 49 of file HDC2080.h.

◆ HH_STATUS

#define HH_STATUS   0x10

Definition at line 45 of file HDC2080.h.

◆ HL_ENABLE

#define HL_ENABLE   0x08

Definition at line 50 of file HDC2080.h.

◆ HL_STATUS

#define HL_STATUS   0x08

Definition at line 46 of file HDC2080.h.

◆ HUM_OFFSET_ADJUST

#define HUM_OFFSET_ADJUST   0x09

Definition at line 62 of file HDC2080.h.

◆ HUMID_HIGH

#define HUMID_HIGH   0x03

Definition at line 56 of file HDC2080.h.

◆ HUMID_LOW

#define HUMID_LOW   0x02

Definition at line 55 of file HDC2080.h.

◆ HUMID_MAX

#define HUMID_MAX   0x06

Definition at line 59 of file HDC2080.h.

◆ HUMID_ONLY

#define HUMID_ONLY   2

Definition at line 23 of file HDC2080.h.

◆ HUMID_THR_H

#define HUMID_THR_H   0x0D

Definition at line 66 of file HDC2080.h.

◆ HUMID_THR_L

#define HUMID_THR_L   0x0C

Definition at line 65 of file HDC2080.h.

◆ INTERRUPT_CONFIG

#define INTERRUPT_CONFIG   0x07

Definition at line 60 of file HDC2080.h.

◆ INTERRUPT_DRDY

#define INTERRUPT_DRDY   0x04

Definition at line 57 of file HDC2080.h.

◆ LEVEL_MODE

#define LEVEL_MODE   0

Definition at line 26 of file HDC2080.h.

◆ MAN_ID

#define MAN_ID   0x5449

Definition at line 40 of file HDC2080.h.

◆ MANUAL

#define MANUAL   0

Definition at line 30 of file HDC2080.h.

◆ MEASUREMENT_CONFIG

#define MEASUREMENT_CONFIG   0x0F

Definition at line 68 of file HDC2080.h.

◆ MID_H

#define MID_H   0xFD

Definition at line 70 of file HDC2080.h.

◆ MID_L

#define MID_L   0xFC

Definition at line 69 of file HDC2080.h.

◆ NINE_BIT

#define NINE_BIT   2

Definition at line 18 of file HDC2080.h.

◆ ONE_HZ

#define ONE_HZ   5

Definition at line 35 of file HDC2080.h.

◆ ONE_MINS

#define ONE_MINS   2

Definition at line 32 of file HDC2080.h.

◆ TEMP_AND_HUMID

#define TEMP_AND_HUMID   0

Definition at line 21 of file HDC2080.h.

◆ TEMP_HIGH

#define TEMP_HIGH   0x01

Definition at line 54 of file HDC2080.h.

◆ TEMP_LOW

#define TEMP_LOW   0x00

Definition at line 53 of file HDC2080.h.

◆ TEMP_MAX

#define TEMP_MAX   0x05

Definition at line 58 of file HDC2080.h.

◆ TEMP_OFFSET_ADJUST

#define TEMP_OFFSET_ADJUST   0x08

Definition at line 61 of file HDC2080.h.

◆ TEMP_ONLY

#define TEMP_ONLY   1

Definition at line 22 of file HDC2080.h.

◆ TEMP_THR_H

#define TEMP_THR_H   0x0B

Definition at line 64 of file HDC2080.h.

◆ TEMP_THR_L

#define TEMP_THR_L   0x0A

Definition at line 63 of file HDC2080.h.

◆ TEN_SECONDS

#define TEN_SECONDS   3

Definition at line 33 of file HDC2080.h.

◆ TH_ENABLE

#define TH_ENABLE   0x40

Definition at line 47 of file HDC2080.h.

◆ TH_STATUS

#define TH_STATUS   0x40

Definition at line 43 of file HDC2080.h.

◆ TL_ENABLE

#define TL_ENABLE   0x20

Definition at line 48 of file HDC2080.h.

◆ TL_STATUS

#define TL_STATUS   0x20

Definition at line 44 of file HDC2080.h.

◆ TWO_HZ

#define TWO_HZ   6

Definition at line 36 of file HDC2080.h.

◆ TWO_MINS

#define TWO_MINS   1

Definition at line 31 of file HDC2080.h.

Function Documentation

◆ clearMaxHumidity()

void clearMaxHumidity ( void )

Resets the Maximum Humidity peak-hold register to 0.

Definition at line 726 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearMaxTemp()

void clearMaxTemp ( void )

Resets the Maximum Temperature peak-hold register to 0.

Definition at line 715 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disableDRDYInterrupt()

void disableDRDYInterrupt ( void )

Disables the Data Ready (DRDY) interrupt.

Definition at line 821 of file HDC2080.c.

Here is the call graph for this function:

◆ disableHeater()

void disableHeater ( void )

Disables the internal heating element of the HDC2080.

Definition at line 150 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disableInterrupt()

void disableInterrupt ( void )

Disables the physical interrupt/DRDY pin (sets to High-Z).

Definition at line 567 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disableThresholdInterrupt()

void disableThresholdInterrupt ( void )

Disables the high/low temperature and humidity threshold interrupts.

Definition at line 789 of file HDC2080.c.

Here is the call graph for this function:

◆ enableDRDYInterrupt()

void enableDRDYInterrupt ( void )

Enables the Data Ready (DRDY) interrupt.

Definition at line 805 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enableHeater()

void enableHeater ( void )

Enables the internal heating element of the HDC2080.

Definition at line 133 of file HDC2080.c.

Here is the call graph for this function:

◆ enableInterrupt()

void enableInterrupt ( void )

Enables the physical interrupt/DRDY pin.

Definition at line 549 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enableThresholdInterrupt()

void enableThresholdInterrupt ( void )

Enables the high/low temperature and humidity threshold interrupts.

Definition at line 773 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initHDC2080()

int initHDC2080 ( void )

Initializes the HDC2080 sensor with default parameters.

Returns
TRUE if the sensor is found and initialized, FALSE otherwise.

Definition at line 839 of file HDC2080.c.

◆ readHighHumidityThreshold()

float readHighHumidityThreshold ( void )

Reads the high humidity threshold currently set in the sensor.

Returns
Humidity threshold as a percentage.

Definition at line 344 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readHighTempThreshold()

float readHighTempThreshold ( void )

Reads the high temperature threshold currently set in the sensor.

Returns
Temperature threshold in degrees Celsius.

Definition at line 378 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readHumidity()

float readHumidity ( void )

Reads the relative humidity from the HDC2080 sensor.

Returns
Relative humidity as a percentage (0.0 to 100.0).

Definition at line 79 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readHumidityOffsetAdjust()

uint8_t readHumidityOffsetAdjust ( void )

Reads the humidity offset adjustment value from the sensor.

Returns
The 8-bit offset value from the HUM_OFFSET_ADJUST register.

Definition at line 101 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readInterruptStatus()

uint8_t readInterruptStatus ( void )

Reads the interrupt status register.

Returns
Bitmask of triggered interrupts (DRDY, TH, TL, HH, HL).

Definition at line 702 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readLowHumidityThreshold()

float readLowHumidityThreshold ( void )

Reads the low humidity threshold currently set in the sensor.

Returns
Humidity threshold as a percentage.

Definition at line 327 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readLowTempThreshold()

float readLowTempThreshold ( void )

Reads the low temperature threshold currently set in the sensor.

Returns
Temperature threshold in degrees Celsius.

Definition at line 361 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readMaxHumidity()

float readMaxHumidity ( void )

Reads the maximum humidity recorded since the last clear.

Returns
Maximum relative humidity as a percentage.

Definition at line 757 of file HDC2080.c.

Here is the call graph for this function:

◆ readMaxTemp()

float readMaxTemp ( void )

Reads the highest temperature recorded since the last clear.

Returns
Maximum temperature in degrees Celsius.

Definition at line 739 of file HDC2080.c.

Here is the call graph for this function:

◆ readReg()

uint8_t readReg ( uint8_t reg,
uint8_t * data,
uint8_t count )

Reads a specified number of bytes from a sensor register over I2C.

Parameters
regThe register address to read from.
dataPointer to the buffer where received data will be stored.
countNumber of bytes to read.
Returns
Returns TRUE (1) upon completion.

Definition at line 172 of file HDC2080.c.

Here is the caller graph for this function:

◆ readTemp()

float readTemp ( void )

Reads the temperature data from the HDC2080 sensor.

Returns
Temperature in degrees Celsius.

Definition at line 24 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readTempOffsetAdjust()

uint8_t readTempOffsetAdjust ( void )

Reads the temperature offset adjustment value.

Returns
The 8-bit offset value from the register.

Definition at line 46 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void reset ( void )

Performs a software reset on the HDC2080.

Definition at line 529 of file HDC2080.c.

Here is the call graph for this function:

◆ setHighHumidity()

void setHighHumidity ( float humid)

Sets the high humidity threshold for the interrupt pin.

Parameters
humidHumidity threshold in percentage (0 to 100).

Definition at line 281 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setHighTemp()

void setHighTemp ( float temp)

Sets the high temperature threshold for the interrupt pin.

Parameters
tempTemperature threshold in degrees Celsius (-40 to 125).

Definition at line 258 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setHumidityOffsetAdjust()

uint8_t setHumidityOffsetAdjust ( uint8_t value)

Sets the humidity offset adjustment value.

Parameters
valueThe 8-bit offset value to write.
Returns
The value read back from the register after writing.

Definition at line 119 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setHumidRes()

void setHumidRes ( int resolution)

Sets the humidity measurement resolution.

Parameters
resolution0 for 14-bit, 1 for 11-bit, 2 for 9-bit.

Definition at line 437 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setInterruptMode()

void setInterruptMode ( int mode)

Sets the interrupt pin to either level-sensitive or comparator mode.

Parameters
mode0 for LEVEL_MODE, 1 for COMPARATOR_MODE.

Definition at line 673 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setInterruptPolarity()

void setInterruptPolarity ( int polarity)

Configures the electrical behavior of the INT pin when active.

Parameters
polarity0 for ACTIVE_LOW, 1 for ACTIVE_HIGH.

Definition at line 644 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLowHumidity()

void setLowHumidity ( float humid)

Sets the low humidity threshold for the interrupt pin.

Parameters
humidHumidity threshold in percentage (0 to 100).

Definition at line 304 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLowTemp()

void setLowTemp ( float temp)

Sets the low temperature threshold for the interrupt pin.

Parameters
tempTemperature threshold in degrees Celsius (-40 to 125).

Definition at line 235 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMeasurementMode()

void setMeasurementMode ( int mode)

Configures whether the sensor measures Temp, Humidity, or both.

Parameters
mode0: Temp & Humid, 1: Temp only, 2: Humid only.

Definition at line 475 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setRate()

void setRate ( int rate)

Sets the automatic measurement frequency.

Parameters
rateConstant representing the frequency (e.g., ONE_HZ, FIVE_SECONDS).

Definition at line 585 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTempOffsetAdjust()

uint8_t setTempOffsetAdjust ( uint8_t value)

Sets the temperature offset adjustment value.

Parameters
valueThe 8-bit offset value to write (see datasheet page 22).
Returns
The value read back from the register after writing.

Definition at line 63 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTempRes()

void setTempRes ( int resolution)

Sets the temperature measurement resolution.

Parameters
resolution0 for 14-bit, 1 for 11-bit, 2 for 9-bit.

Definition at line 398 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ triggerMeasurement()

void triggerMeasurement ( void )

Manually triggers a single measurement cycle.

Definition at line 511 of file HDC2080.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeReg()

uint8_t writeReg ( uint8_t reg,
uint8_t * data,
uint8_t count )

Writes a specified number of bytes to a sensor register over I2C.

Parameters
regThe register address to write to.
dataPointer to the buffer containing data to be written.
countNumber of bytes to write.
Returns
Returns TRUE (1) upon completion.

Definition at line 206 of file HDC2080.c.

Here is the caller graph for this function: