7static const char *
const TAG =
"sht4x";
9static const uint8_t MEASURECOMMANDS[] = {0xFD, 0xF6, 0xE0};
14 ESP_LOGD(TAG,
"Heater turning on");
21 auto err = this->
write(
nullptr, 0);
28 uint32_t heater_interval =
static_cast<uint32_t
>(
static_cast<uint16_t
>(this->
heater_time_) / this->
duty_cycle_);
29 ESP_LOGD(TAG,
"Heater interval: %" PRIu32, heater_interval);
57 ESP_LOGCONFIG(TAG,
"SHT4x:");
60 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
78 ESP_LOGW(TAG,
"Sensor read failed");
88 float sensor_value_temp = buffer[0];
89 float temp = -45 + 175 * sensor_value_temp / 65535;
96 float sensor_value_rh = buffer[1];
97 float rh = -6 + 125 * sensor_value_rh / 65535;
virtual void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message=nullptr)
void set_interval(const std::string &name, uint32_t interval, std::function< void()> &&f)
Set an interval function with a unique name.
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.
void status_set_error(const char *message=nullptr)
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.