10static const char *
const TAG =
"honeywell_hih.i2c";
12static const uint8_t REQUEST_CMD[1] = {0x00};
13static const uint16_t MAX_COUNT = 0x3FFE;
15void HoneywellHIComponent::read_sensor_data_() {
19 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
24 const uint16_t raw_humidity = (
static_cast<uint16_t
>(data[0] & 0x3F) << 8) | data[1];
25 float humidity = (
static_cast<float>(raw_humidity) / MAX_COUNT) * 100;
27 const uint16_t raw_temperature = (
static_cast<uint16_t
>(data[2]) << 6) | (data[3] >> 2);
28 float temperature = (
static_cast<float>(raw_temperature) / MAX_COUNT) * 165 - 40;
30 ESP_LOGD(TAG,
"Got temperature=%.2f°C humidity=%.2f%%",
temperature, humidity);
37void HoneywellHIComponent::start_measurement_() {
39 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
47bool HoneywellHIComponent::is_measurement_ready_() {
51 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
57 return ((data[0] & 0xC0) == 0x00);
60void HoneywellHIComponent::measurement_timeout_() {
61 ESP_LOGE(TAG,
"Honeywell HIH Timeout!");
67 ESP_LOGV(TAG,
"Update Honeywell HIH Sensor");
69 this->start_measurement_();
71 this->
set_timeout(
"meas_timeout", 100, [
this] { this->measurement_timeout_(); });
78 this->read_sensor_data_();
83 ESP_LOGD(TAG,
"Honeywell HIH:");
86 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
90 LOG_UPDATE_INTERVAL(
this);
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.