8static const char *
const TAG =
"hdc2010";
11static constexpr uint8_t REG_TEMPERATURE_LOW = 0x00;
12static constexpr uint8_t REG_TEMPERATURE_HIGH = 0x01;
13static constexpr uint8_t REG_HUMIDITY_LOW = 0x02;
14static constexpr uint8_t REG_HUMIDITY_HIGH = 0x03;
15static constexpr uint8_t REG_RESET_DRDY_INT_CONF = 0x0E;
16static constexpr uint8_t REG_MEASUREMENT_CONF = 0x0F;
19static constexpr uint8_t MEAS_TRIG = 0x01;
20static constexpr uint8_t MEAS_CONF_MASK = 0x06;
21static constexpr uint8_t HRES_MASK = 0x30;
22static constexpr uint8_t TRES_MASK = 0xC0;
25static constexpr uint8_t AMM_MASK = 0x70;
28 ESP_LOGCONFIG(TAG,
"Running setup");
31 uint8_t config_contents;
32 this->
read_register(REG_MEASUREMENT_CONF, &config_contents, 1);
33 config_contents &= ~(TRES_MASK | HRES_MASK | MEAS_CONF_MASK);
34 this->
write_bytes(REG_MEASUREMENT_CONF, &config_contents, 1);
37 this->
read_register(REG_RESET_DRDY_INT_CONF, &config_contents, 1);
38 config_contents &= ~AMM_MASK;
39 this->
write_bytes(REG_RESET_DRDY_INT_CONF, &config_contents, 1);
43 ESP_LOGCONFIG(TAG,
"HDC2010:");
46 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
48 LOG_UPDATE_INTERVAL(
this);
55 uint8_t config_contents;
56 this->
read_register(REG_MEASUREMENT_CONF, &config_contents, 1);
57 config_contents |= MEAS_TRIG;
58 this->
write_bytes(REG_MEASUREMENT_CONF, &config_contents, 1);
65 ESP_LOGD(TAG,
"Temp=%.1f°C", temp);
71 ESP_LOGD(TAG,
"Humidity=%.1f%%", humidity);
83 return (
float) temp * 0.0025177f - 40.0f;
93 return (
float) humidity * 0.001525879f;
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") void set_timeout(const std voi set_timeout)(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
void update() override
Retrieve the latest sensor values. This operation takes approximately 16ms.
sensor::Sensor * temperature_sensor_
void dump_config() override
void setup() override
Setup the sensor and check for connection.
sensor::Sensor * humidity_sensor_
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len)
reads an array of bytes from a specific register in the I²C device
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len) const
void publish_state(float state)
Publish a new state to the front-end.
Providing packet encoding functions for exchanging data with a remote host.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.