Arduino TKJHAT
Arduino library for Pico HAT extension board
Loading...
Searching...
No Matches
HDC2021.h
1#ifndef HDC2021_H
2#define HDC2021_H
3
34
35#include <Arduino.h>
36#include <Wire.h>
37#include "pins.h"
38
39class HDC2021 {
40 private:
41 uint8_t sdaPin;
42 uint8_t sclPin;
43 uint8_t interruptPin;
44
45 uint8_t readRegister(uint8_t reg);
46 void writeRegister(uint8_t reg, uint8_t value);
47 void reset();
48 void setMeasurementMode();
49 void setRate();
50 void setTempRes();
51 void setHumidityRes();
52 void triggerMeasurement();
53
54 public:
55
62 HDC2021(uint8_t sdaPin, uint8_t sclPin, uint8_t interruptPin);
63
72
73 void begin();
74
79 void setLowTempThreshold(float temp);
80
85 void setHighTempThreshold(float temp);
86
91 void setLowHumidityThreshold(float humid);
92
97 void setHighHumidityThreshold(float humid);
98
104
110
115 void stop();
116};
117
122#endif
float readHumidity()
Read the current relative humidity in percentage.
float readTemperature()
Read the current temperature in degrees Celsius.
void setLowHumidityThreshold(float humid)
Set the low humidity threshold.
void begin()
Initialize the HDC2021 sensor (HDC2021_I2C_ADDRESS — 0x40).
void setHighTempThreshold(float temp)
Set the high temperature threshold.
HDC2021(uint8_t sdaPin, uint8_t sclPin, uint8_t interruptPin)
Construct a new HDC2021 object with specified I2C pins and optional interrupt pin.
void setHighHumidityThreshold(float humid)
Set the high humidity threshold.
void stop()
Stop the HDC2021 sensor.
void setLowTempThreshold(float temp)
Set the low temperature threshold.