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;
28 ESP_LOGCONFIG(TAG,
"Running setup");
32 uint16_t device_id_register;
34 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
41 if ((device_id_register & 0x3F) == 0x07) {
42 if (device_id_register & 0x800) {
53 ESP_LOGCONFIG(TAG,
"SHTCx:");
57 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
59 LOG_UPDATE_INTERVAL(
this);
69 ESP_LOGW(TAG,
"Retrying communication");
76 ESP_LOGE(TAG,
"Polling failed");
90 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
93 temperature = 175.0f * float(raw_data[0]) / 65536.0f - 45.0f;
94 humidity = 100.0f * float(raw_data[1]) / 65536.0f;
96 ESP_LOGD(TAG,
"Temperature=%.2f°C Humidity=%.2f%%",
temperature, humidity);
virtual void mark_failed()
Mark this component as failed.
bool status_has_warning() const
void status_set_warning(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.
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)