15#include <zephyr/drivers/i2c.h>
33 temp = (
byte[1] << 8) |
byte[0];
35 f = ((temp * 165.0f) / 65536.0f) - 40.0f;
88 humidity = (
byte[1] << 8) |
byte[0];
90 f = (humidity / 65536.0f) * 100.0f;
135 uint8_t configContents;
140 configContents = (configContents | 0x08);
152 uint8_t configContents;
157 configContents = (configContents & 0xF7);
172uint8_t
readReg(uint8_t reg, uint8_t *data, uint8_t count) {
206uint8_t
writeReg(uint8_t reg, uint8_t *data, uint8_t count) {
215 for (i = 0; i < count; i++)
216 datas[i + 1] = data[i];
236 uint8_t temp_thresh_low;
241 }
else if (temp > 125.0f) {
246 temp_thresh_low = (uint8_t)(256.0f * (temp + 40.0f) / 165.0f);
259 uint8_t temp_thresh_high;
264 }
else if (temp > 125.0f) {
269 temp_thresh_high = (uint8_t)(256.0f * (temp + 40.0f) / 165.0f);
282 uint8_t humid_thresh;
287 }
else if (humid > 100.0f) {
292 humid_thresh = (uint8_t)(256.0f * humid / 100.0f);
305 uint8_t humid_thresh;
310 }
else if (humid > 100.0f) {
315 humid_thresh = (uint8_t)(256.0f * humid / 100.0f);
332 float f = regContents;
333 f = f * 100.0f / 256.0f;
349 float f = regContents;
350 f = f * 100.0f / 256.0f;
366 float f = regContents;
367 f = (f * 165.0f / 256.0f) - 40.0f;
383 float f = regContents;
384 f = (f * 165.0f / 256.0f) - 40.0f;
400 uint8_t configContents;
405 switch (resolution) {
407 configContents = (configContents & 0x3F);
411 configContents = (configContents & 0x7F);
412 configContents = (configContents | 0x40);
416 configContents = (configContents & 0xBF);
417 configContents = (configContents | 0x80);
421 configContents = (configContents & 0x3F);
439 uint8_t configContents;
443 switch (resolution) {
445 configContents = (configContents & 0xCF);
449 configContents = (configContents & 0xDF);
450 configContents = (configContents | 0x10);
454 configContents = (configContents & 0xEF);
455 configContents = (configContents | 0x20);
459 configContents = (configContents & 0xCF);
477 uint8_t configContents;
483 configContents = (configContents & 0xF9);
487 configContents = (configContents & 0xFC);
488 configContents = (configContents | 0x02);
492 configContents = (configContents & 0xFD);
493 configContents = (configContents | 0x04);
497 configContents = (configContents & 0xF9);
513 uint8_t configContents;
518 configContents = (configContents | 0x01);
531 uint8_t configContents;
536 configContents = (configContents | 0x80);
551 uint8_t configContents;
556 configContents = (configContents | 0x04);
569 uint8_t configContents;
574 configContents = (configContents & 0xFB);
587 uint8_t configContents;
593 configContents = (configContents & 0x8F);
597 configContents = (configContents & 0x9F);
598 configContents = (configContents | 0x10);
602 configContents = (configContents & 0xAF);
603 configContents = (configContents | 0x20);
607 configContents = (configContents & 0xBF);
608 configContents = (configContents | 0x30);
612 configContents = (configContents & 0xCF);
613 configContents = (configContents | 0x40);
617 configContents = (configContents & 0xDF);
618 configContents = (configContents | 0x50);
622 configContents = (configContents & 0xEF);
623 configContents = (configContents | 0x60);
627 configContents = (configContents | 0x70);
631 configContents = (configContents & 0x8F);
646 uint8_t configContents;
652 configContents = (configContents & 0xFD);
656 configContents = (configContents | 0x02);
660 configContents = (configContents & 0xFD);
675 uint8_t configContents;
681 configContents = (configContents & 0xFE);
685 configContents = (configContents | 0x01);
689 configContents = (configContents & 0xFE);
744 float f = regContents;
745 f = (f * 165.0f / 256.0f) - 40.0f;
762 float f = regContents;
763 f = (f / 256.0f) * 100.0f;
779 regContents = (regContents | 0x78);
795 regContents = (regContents & 0x87);
811 regContents = (regContents | 0x80);
827 regContents = (regContents & 0x7F);
840 unsigned char datas[6] = {0};
844 manfID = (datas[1] << 8) | datas[0];
845 deviceID = (datas[3] << 8) | datas[2];
850 myPrintkW(
"HDC2080 Temp/Humidty Sensor not found\r\n");
898 myPrintkW(
"HDC2080 automatic trigger Enabled\r\n");
920 myPrintkI(
"HDC2080 Temp/Humidty Present\r\n");
uint8_t readTempOffsetAdjust(void)
Reads the temperature offset adjustment value.
void setInterruptPolarity(int polarity)
Configures the electrical behavior of the INT pin when active.
void clearMaxHumidity(void)
Resets the Maximum Humidity peak-hold register to 0.
uint8_t readReg(uint8_t reg, uint8_t *data, uint8_t count)
Reads a specified number of bytes from a sensor register over I2C.
void enableThresholdInterrupt(void)
Enables the high/low temperature and humidity threshold interrupts.
float readMaxTemp(void)
Reads the highest temperature recorded since the last clear.
void reset(void)
Performs a software reset on the HDC2080.
void setRate(int rate)
Sets the automatic measurement frequency.
void setLowHumidity(float humid)
Sets the low humidity threshold for the interrupt pin.
void enableInterrupt(void)
Enables the physical interrupt/DRDY pin.
void setMeasurementMode(int mode)
Configures whether the sensor measures Temp, Humidity, or both.
void enableHeater(void)
Enables the internal heating element of the HDC2080.
float readMaxHumidity(void)
Reads the maximum humidity recorded since the last clear.
void setTempRes(int resolution)
Sets the temperature measurement resolution.
float readLowTempThreshold(void)
Reads the low temperature threshold currently set in the sensor.
void setHighHumidity(float humid)
Sets the high humidity threshold for the interrupt pin.
void setHumidRes(int resolution)
Sets the humidity measurement resolution.
float readHighTempThreshold(void)
Reads the high temperature threshold currently set in the sensor.
uint8_t setTempOffsetAdjust(uint8_t value)
Sets the temperature offset adjustment value.
void setLowTemp(float temp)
Sets the low temperature threshold for the interrupt pin.
float readHumidity(void)
Reads the relative humidity from the HDC2080 sensor.
void setHighTemp(float temp)
Sets the high temperature threshold for the interrupt pin.
uint8_t readHumidityOffsetAdjust(void)
Reads the humidity offset adjustment value from the sensor.
void disableThresholdInterrupt(void)
Disables the high/low temperature and humidity threshold interrupts.
uint8_t setHumidityOffsetAdjust(uint8_t value)
Sets the humidity offset adjustment value.
int initHDC2080(void)
Initializes the HDC2080 sensor with default parameters.
void triggerMeasurement(void)
Manually triggers a single measurement cycle.
void enableDRDYInterrupt(void)
Enables the Data Ready (DRDY) interrupt.
void disableHeater(void)
Disables the internal heating element of the HDC2080.
float readHighHumidityThreshold(void)
Reads the high humidity threshold currently set in the sensor.
void disableDRDYInterrupt(void)
Disables the Data Ready (DRDY) interrupt.
float readLowHumidityThreshold(void)
Reads the low humidity threshold currently set in the sensor.
void clearMaxTemp(void)
Resets the Maximum Temperature peak-hold register to 0.
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 disableInterrupt(void)
Disables the physical interrupt/DRDY pin (sets to High-Z).
float readTemp(void)
Reads the temperature data from the HDC2080 sensor.
uint8_t readInterruptStatus(void)
Reads the interrupt status register.
void setInterruptMode(int mode)
Sets the interrupt pin to either level-sensitive or comparator mode.
#define TEMP_OFFSET_ADJUST
#define HUM_OFFSET_ADJUST
#define MEASUREMENT_CONFIG
flashParametersStruct flashParameters
working valuses of flash parameters in RAM
uint32_t sensorTypePresentAll
common struct, enum, externs, prototypes
int myPrintkI(char *restrict fmt,...)
prints an information message to the UART
const struct device *const i2c_dev
get the device structure for the I2C device defined by I2C_DEV_NODE
int myPrintkW(char *restrict fmt,...)
prints a warning message to the UART