8static const char *
const TAG =
"sht4x";
10static const uint8_t MEASURECOMMANDS[] = {0xFD, 0xF6, 0xE0};
11static const uint8_t SERIAL_NUMBER_COMMAND = 0x89;
14static constexpr float TEMPERATURE_OFFSET = -45.0f;
15static constexpr float TEMPERATURE_SPAN = 175.0f;
16static constexpr float HUMIDITY_OFFSET = -6.0f;
17static constexpr float HUMIDITY_SPAN = 125.0f;
18static constexpr float RAW_MAX = 65535.0f;
23 ESP_LOGE(TAG,
"Get serial number failed");
32 auto err = this->
write(
nullptr, 0);
70 " Serial number: %08" PRIx32,
75 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
78 ESP_LOGW(TAG,
"Get serial number failed");
96 ESP_LOGW(TAG,
"Sensor read failed");
106 float temp = TEMPERATURE_OFFSET + TEMPERATURE_SPAN *
static_cast<float>(buffer[0]) / RAW_MAX;
112 float rh = HUMIDITY_OFFSET + HUMIDITY_SPAN *
static_cast<float>(buffer[1]) / RAW_MAX;
121 ESP_LOGD(TAG,
"Heater turning on");
void mark_failed()
Mark this component as failed.
void status_set_warning()
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 status_clear_warning()
ErrorCode write(const uint8_t *data, size_t len) const
writes an array of bytes to a device using an I2CBus
bool get_8bit_register(uint8_t i2c_register, uint16_t *data, uint8_t len, uint8_t delay=0)
get data words from I2C register.
bool write_command(T i2c_register)
Write a command to the I2C device.
bool read_data(uint16_t *data, uint8_t len)
Read data words from I2C device.
void publish_state(float state)
Publish a new state to the front-end.
SHT4XPRECISION precision_
void read_serial_number_()
SHT4XHEATERPOWER heater_power_
uint32_t last_heater_millis_
sensor::Sensor * humidity_sensor_
sensor::Sensor * temp_sensor_
uint32_t heater_interval_
void dump_config() override
SHT4XHEATERTIME heater_time_
@ ERROR_OK
No error found during execution of method.
Providing packet encoding functions for exchanging data with a remote host.
uint32_t IRAM_ATTR HOT millis()