7static const char *
const TAG =
"sht4x";
9static const uint8_t MEASURECOMMANDS[] = {0xFD, 0xF6, 0xE0};
14 ESP_LOGD(TAG,
"Heater turning on");
21 ESP_LOGCONFIG(TAG,
"Setting up sht4x...");
23 auto err = this->
write(
nullptr, 0);
30 uint32_t heater_interval =
static_cast<uint32_t
>(
static_cast<uint16_t
>(this->
heater_time_) / this->
duty_cycle_);
31 ESP_LOGD(TAG,
"Heater interval: %" PRIu32, heater_interval);
59 ESP_LOGCONFIG(TAG,
"SHT4x:");
62 ESP_LOGE(TAG,
"Communication with SHT4x failed!");
80 ESP_LOGW(TAG,
"Sensor read failed");
90 float sensor_value_temp = buffer[0];
91 float temp = -45 + 175 * sensor_value_temp / 65535;
98 float sensor_value_rh = buffer[1];
99 float rh = -6 + 125 * sensor_value_rh / 65535;
virtual void mark_failed()
Mark this component as failed.
void set_interval(const std::string &name, uint32_t interval, std::function< void()> &&f)
Set an interval function with a unique name.
void status_set_warning(const char *message="unspecified")
void status_set_error(const char *message="unspecified")
void status_clear_warning()
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
ErrorCode write(const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a device using an I2CBus
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_
SHT4XHEATERPOWER heater_power_
sensor::Sensor * humidity_sensor_
sensor::Sensor * temp_sensor_
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.