6static const char *
const TAG =
"sht3xd";
17static const uint16_t SHT3XD_COMMAND_READ_SERIAL_NUMBER_CLOCK_STRETCHING = 0x3780;
18static const uint16_t SHT3XD_COMMAND_READ_SERIAL_NUMBER = 0x3682;
20static const uint16_t SHT3XD_COMMAND_READ_STATUS = 0xF32D;
21static const uint16_t SHT3XD_COMMAND_CLEAR_STATUS = 0x3041;
22static const uint16_t SHT3XD_COMMAND_HEATER_ENABLE = 0x306D;
23static const uint16_t SHT3XD_COMMAND_HEATER_DISABLE = 0x3066;
24static const uint16_t SHT3XD_COMMAND_SOFT_RESET = 0x30A2;
25static const uint16_t SHT3XD_COMMAND_POLLING_H = 0x2400;
26static const uint16_t SHT3XD_COMMAND_FETCH_DATA = 0xE000;
29 uint16_t raw_serial_number[2]{0};
30 if (!this->
get_register(SHT3XD_COMMAND_READ_SERIAL_NUMBER_CLOCK_STRETCHING, raw_serial_number, 2)) {
31 if (!this->
get_register(SHT3XD_COMMAND_READ_SERIAL_NUMBER, raw_serial_number, 2, 10)) {
32 ESP_LOGW(TAG,
"Serial number read failed, continuing without it (clone or non-standard sensor)");
38 this->
mark_failed(LOG_STR(
"Failed to set heater mode"));
46 " Serial Number: 0x%08" PRIX32
"\n"
47 " Heater Enabled: %s",
50 LOG_UPDATE_INTERVAL(
this);
57 ESP_LOGD(TAG,
"Retrying to reconnect the sensor.");
72 float temperature = 175.0f * float(raw_data[0]) / 65535.0f - 45.0f;
73 float humidity = 100.0f * float(raw_data[1]) / 65535.0f;
75 ESP_LOGD(TAG,
"Got temperature=%.2f°C humidity=%.2f%%",
temperature, humidity);
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.
bool status_has_warning() const
void status_clear_warning()
bool get_register(uint16_t command, 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.
sensor::Sensor * temperature_sensor_
sensor::Sensor * humidity_sensor_
void dump_config() override