Data Logger BLE Cellular Board
Loading...
Searching...
No Matches
HDC2080.c File Reference

Description: This library facilitates communication with, and configuration of, the HDC2080 Temperature and Humidity Sensor. It makes extensive use of the Wire.H library, and should be useable with both Arduino and Energia. More...

#include "jfet_files/HDC2080.h"
#include "jfet_files/jfet_common.h"
#include <stdint.h>
#include <stdio.h>
#include <zephyr/drivers/i2c.h>

Go to the source code of this file.

Functions

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 value)
 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 value)
 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.
 
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.
 
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 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 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).
 
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 mode)
 Sets the interrupt pin to either level-sensitive or comparator mode.
 
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.
 
int initHDC2080 (void)
 Initializes the HDC2080 sensor with default parameters.
 

Detailed Description

Description: This library facilitates communication with, and configuration of, the HDC2080 Temperature and Humidity Sensor. It makes extensive use of the Wire.H library, and should be useable with both Arduino and Energia.

Note
code is release AS-IS into the public domain, no guarantee or warranty is given.
Author
HDC2010.cpp originally created by: Brandon Fisher, August 1st 2017

Definition in file HDC2080.c.

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.

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

◆ 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: