7 static const char *
const TAG =
"sht4x";
9 static const uint8_t MEASURECOMMANDS[] = {0xFD, 0xF6, 0xE0};
14 ESP_LOGD(TAG,
"Heater turning on");
19 ESP_LOGCONFIG(TAG,
"Setting up sht4x...");
23 ESP_LOGD(TAG,
"Heater interval: %" PRIu32, heater_interval);
60 bool read_status = this->
read_data(buffer, 2);
66 float sensor_value_temp = buffer[0];
67 float temp = -45 + 175 * sensor_value_temp / 65535;
74 float sensor_value_rh = buffer[1];
75 float rh = -6 + 125 * sensor_value_rh / 65535;
80 ESP_LOGD(TAG,
"Sensor read failed");
SHT4XHEATERPOWER heater_power_
void set_interval(const std::string &name, uint32_t interval, std::function< void()> &&f)
Set an interval function with a unique name.
bool write_command(T i2c_register)
Write a command to the i2c device.
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
SHT4XPRECISION precision_
bool read_data(uint16_t *data, uint8_t len)
Read data words from i2c device.
sensor::Sensor * temp_sensor_
ErrorCode write(const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a device using an I2CBus
void publish_state(float state)
Publish a new state to the front-end.
Implementation of SPI Controller mode.
void dump_config() override
sensor::Sensor * humidity_sensor_
SHT4XHEATERTIME heater_time_