8static const char *
const TAG =
"shtcx";
10static const uint16_t SHTCX_COMMAND_SLEEP = 0xB098;
11static const uint16_t SHTCX_COMMAND_WAKEUP = 0x3517;
12static const uint16_t SHTCX_COMMAND_READ_ID_REGISTER = 0xEFC8;
13static const uint16_t SHTCX_COMMAND_SOFT_RESET = 0x805D;
14static const uint16_t SHTCX_COMMAND_POLLING_H = 0x7866;
31 uint16_t device_id_register;
33 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
40 if ((device_id_register & 0x3F) == 0x07) {
41 if (device_id_register & 0x800) {
58 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
60 LOG_UPDATE_INTERVAL(
this);
70 ESP_LOGW(TAG,
"Retrying communication");
77 ESP_LOGE(TAG,
"Polling failed");
91 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
94 temperature = 175.0f * float(raw_data[0]) / 65536.0f - 45.0f;
95 humidity = 100.0f * float(raw_data[1]) / 65536.0f;
97 ESP_LOGD(TAG,
"Temperature=%.2f°C Humidity=%.2f%%",
temperature, humidity);
virtual void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message=nullptr)
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 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 * humidity_sensor_
sensor::Sensor * temperature_sensor_
void dump_config() override
float get_setup_priority() const override
const float DATA
For components that import data from directly connected sensors like DHT.
const char * to_string(SHTCXType type)
Providing packet encoding functions for exchanging data with a remote host.
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)