Data Logger BLE Cellular Board
Loading...
Searching...
No Matches
HDC2080.h
Go to the documentation of this file.
1/*
2 HDC2080.h
3 HDC2010.h originally created by: Brandon Fisher, August 1st 2017
4
5 This code is release AS-IS into the public domain, no guarantee or warranty is given.
6
7 Description: This header file accompanies HDC2080.cpp, and declares all methods, fields,
8 and constants used in the source code.
9*/
10
11#ifndef HDC2080_h
12#define HDC2080_h
13#include <stdint.h>
14#include <stdio.h>
15// Constants for setting measurement resolution
16#define FOURTEEN_BIT 0
17#define ELEVEN_BIT 1
18#define NINE_BIT 2
19
20// Constants for setting sensor mode
21#define TEMP_AND_HUMID 0
22#define TEMP_ONLY 1
23#define HUMID_ONLY 2
24#define ACTIVE_LOW 0
25#define ACTIVE_HIGH 1
26#define LEVEL_MODE 0
27#define COMPARATOR_MODE 1
28
29// Constants for setting sample rate
30#define MANUAL 0
31#define TWO_MINS 1
32#define ONE_MINS 2
33#define TEN_SECONDS 3
34#define FIVE_SECONDS 4
35#define ONE_HZ 5
36#define TWO_HZ 6
37#define FIVE_HZ 7
38#define HDC_ADDRESS 0x40
39
40#define MAN_ID 0x5449
41#define DEV_ID 0x07D0
42#define DRDY_STATUS 0x80
43#define TH_STATUS 0x40
44#define TL_STATUS 0x20
45#define HH_STATUS 0x10
46#define HL_STATUS 0x08
47#define TH_ENABLE 0x40
48#define TL_ENABLE 0x20
49#define HH_ENABLE 0x10
50#define HL_ENABLE 0x08
51
52// Define Register Map
53#define TEMP_LOW 0x00
54#define TEMP_HIGH 0x01
55#define HUMID_LOW 0x02
56#define HUMID_HIGH 0x03
57#define INTERRUPT_DRDY 0x04
58#define TEMP_MAX 0x05
59#define HUMID_MAX 0x06
60#define INTERRUPT_CONFIG 0x07
61#define TEMP_OFFSET_ADJUST 0x08
62#define HUM_OFFSET_ADJUST 0x09
63#define TEMP_THR_L 0x0A
64#define TEMP_THR_H 0x0B
65#define HUMID_THR_L 0x0C
66#define HUMID_THR_H 0x0D
67#define HDC_CONFIG 0x0E
68#define MEASUREMENT_CONFIG 0x0F
69#define MID_L 0xFC
70#define MID_H 0xFD
71#define DEVICE_ID_L 0xFE
72#define DEVICE_ID_H 0xFF
73
74int initHDC2080(void);
75
76float readTemp(void); // Returns the temperature in degrees C
77uint8_t readTempOffsetAdjust(void); // Returns the offset adjust in binary
78uint8_t setTempOffsetAdjust(uint8_t); // Set and return the offset adjust in binary
79float readHumidity(void); // Returns the relative humidity
80uint8_t readHumidityOffsetAdjust(void); // Returns the offset adjust in binary
81uint8_t setHumidityOffsetAdjust(uint8_t); // Set and return the offset adjust in binary
82void enableHeater(void); // Enables the heating element
83void disableHeater(void); // Disables the heating element
84void setLowTemp(float temp); // Sets low threshold temperature (in c)
85void setHighTemp(float temp); // Sets high threshold temperature (in c)
86void setHighHumidity(float humid); // Sets high Humiditiy threshold
87void setLowHumidity(float humid); // Sets low Humidity threshold
88float readLowHumidityThreshold(void); // Returns contents of low humidity threshold register
89float readHighHumidityThreshold(void); // Returns contents of high humidity threshold register
90float readLowTempThreshold(void); // Returns contents of low temperature threshold register (in C)
91float readHighTempThreshold(void); // Returns contents of high temperature threshold register (in C)
92void triggerMeasurement(void); // Triggers a manual temperature/humidity reading
93void reset(void); // Triggers a software reset
94void enableInterrupt(void); // Enables the interrupt/DRDY pin
95void disableInterrupt(void); // Disables the interrupt/DRDY pin (High Z)
96uint8_t readInterruptStatus(void); // Reads the status of the interrupt register
97void clearMaxTemp(void); // Clears the Maximum temperature register
98void clearMaxHumidity(void); // Clears the Maximum humidity register
99float readMaxTemp(void); // Reads the maximum temperature register
100float readMaxHumidity(void); // Reads the maximum humidity register
101void enableThresholdInterrupt(void); // Enables high and low temperature/humidity interrupts
102void disableThresholdInterrupt(void); // Disables high and low temperature/humidity interrupts
103void enableDRDYInterrupt(void); // Enables data ready interrupt
104void disableDRDYInterrupt(void); // Disables data ready interrupt
105
106/* Sets Temperature & Humidity Resolution, 3 options
107 0 - 14 bit
108 1 - 11 bit
109 2 - 9 bit
110 default - 14 bit */
111void setTempRes(int resolution);
112void setHumidRes(int resolution);
113
114/* Sets measurement mode, 3 options
115 0 - Temperature and Humidity
116 1 - Temperature only
117 2 - Humidity only
118 default - Temperature & Humidity */
119void setMeasurementMode(int mode);
120
121/* Sets reading rate, 8 options
122 0 - Manual
123 1 - reading every 2 minutes
124 2 - reading every minute
125 3 - reading every ten seconds
126 4 - reading every 5 seconds
127 5 - reading every second
128 6 - reading at 2Hz
129 7 - reading at 5Hz
130 default - Manual */
131void setRate(int rate);
132
133/* Sets Interrupt polarity, 2 options
134 0 - Active Low
135 1 - Active High
136 default - Active Low */
137void setInterruptPolarity(int polarity);
138
139/* Sets Interrupt mode, 2 options
140 0 - Level sensitive
141 1 - Comparator mode
142 default - Level sensitive */
143void setInterruptMode(int polarity);
144
145// private:
146uint8_t readReg(uint8_t reg, uint8_t *data, uint8_t count); // Reads bytes starting at reg, returns TRUE if passed
147uint8_t writeReg(uint8_t reg, uint8_t *data, uint8_t count); // Writes bytes starting at reg, returns TRUE if passed
148float readTemp(void);
149//};
150//
151#endif
uint8_t readTempOffsetAdjust(void)
Reads the temperature offset adjustment value.
Definition HDC2080.c:46
void setInterruptPolarity(int polarity)
Configures the electrical behavior of the INT pin when active.
Definition HDC2080.c:644
void clearMaxHumidity(void)
Resets the Maximum Humidity peak-hold register to 0.
Definition HDC2080.c:726
uint8_t readReg(uint8_t reg, uint8_t *data, uint8_t count)
Reads a specified number of bytes from a sensor register over I2C.
Definition HDC2080.c:172
void enableThresholdInterrupt(void)
Enables the high/low temperature and humidity threshold interrupts.
Definition HDC2080.c:773
float readMaxTemp(void)
Reads the highest temperature recorded since the last clear.
Definition HDC2080.c:739
void reset(void)
Performs a software reset on the HDC2080.
Definition HDC2080.c:529
void setRate(int rate)
Sets the automatic measurement frequency.
Definition HDC2080.c:585
void setLowHumidity(float humid)
Sets the low humidity threshold for the interrupt pin.
Definition HDC2080.c:304
void enableInterrupt(void)
Enables the physical interrupt/DRDY pin.
Definition HDC2080.c:549
void setMeasurementMode(int mode)
Configures whether the sensor measures Temp, Humidity, or both.
Definition HDC2080.c:475
void enableHeater(void)
Enables the internal heating element of the HDC2080.
Definition HDC2080.c:133
float readMaxHumidity(void)
Reads the maximum humidity recorded since the last clear.
Definition HDC2080.c:757
void setTempRes(int resolution)
Sets the temperature measurement resolution.
Definition HDC2080.c:398
float readLowTempThreshold(void)
Reads the low temperature threshold currently set in the sensor.
Definition HDC2080.c:361
void setHighHumidity(float humid)
Sets the high humidity threshold for the interrupt pin.
Definition HDC2080.c:281
void setHumidRes(int resolution)
Sets the humidity measurement resolution.
Definition HDC2080.c:437
float readHighTempThreshold(void)
Reads the high temperature threshold currently set in the sensor.
Definition HDC2080.c:378
void setLowTemp(float temp)
Sets the low temperature threshold for the interrupt pin.
Definition HDC2080.c:235
float readHumidity(void)
Reads the relative humidity from the HDC2080 sensor.
Definition HDC2080.c:79
void setHighTemp(float temp)
Sets the high temperature threshold for the interrupt pin.
Definition HDC2080.c:258
uint8_t readHumidityOffsetAdjust(void)
Reads the humidity offset adjustment value from the sensor.
Definition HDC2080.c:101
void disableThresholdInterrupt(void)
Disables the high/low temperature and humidity threshold interrupts.
Definition HDC2080.c:789
int initHDC2080(void)
Initializes the HDC2080 sensor with default parameters.
Definition HDC2080.c:839
void setInterruptMode(int polarity)
Sets the interrupt pin to either level-sensitive or comparator mode.
Definition HDC2080.c:673
void triggerMeasurement(void)
Manually triggers a single measurement cycle.
Definition HDC2080.c:511
void enableDRDYInterrupt(void)
Enables the Data Ready (DRDY) interrupt.
Definition HDC2080.c:805
void disableHeater(void)
Disables the internal heating element of the HDC2080.
Definition HDC2080.c:150
float readHighHumidityThreshold(void)
Reads the high humidity threshold currently set in the sensor.
Definition HDC2080.c:344
void disableDRDYInterrupt(void)
Disables the Data Ready (DRDY) interrupt.
Definition HDC2080.c:821
float readLowHumidityThreshold(void)
Reads the low humidity threshold currently set in the sensor.
Definition HDC2080.c:327
void clearMaxTemp(void)
Resets the Maximum Temperature peak-hold register to 0.
Definition HDC2080.c:715
uint8_t writeReg(uint8_t reg, uint8_t *data, uint8_t count)
Writes a specified number of bytes to a sensor register over I2C.
Definition HDC2080.c:206
void disableInterrupt(void)
Disables the physical interrupt/DRDY pin (sets to High-Z).
Definition HDC2080.c:567
float readTemp(void)
Reads the temperature data from the HDC2080 sensor.
Definition HDC2080.c:24
uint8_t setHumidityOffsetAdjust(uint8_t)
Sets the humidity offset adjustment value.
Definition HDC2080.c:119
uint8_t readInterruptStatus(void)
Reads the interrupt status register.
Definition HDC2080.c:702
uint8_t setTempOffsetAdjust(uint8_t)
Sets the temperature offset adjustment value.
Definition HDC2080.c:63