11static const char *
const TAG =
"dht12";
19 const uint16_t raw_temperature = uint16_t(
data[2]) * 10 + (
data[3] & 0x7F);
21 if ((
data[3] & 0x80) != 0) {
26 const uint16_t raw_humidity = uint16_t(
data[0]) * 10 +
data[1];
27 float humidity = raw_humidity / 10.0f;
29 ESP_LOGD(TAG,
"Got temperature=%.2f°C humidity=%.2f%%",
temperature, humidity);
44 ESP_LOGD(TAG,
"DHT12:");
47 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
55 ESP_LOGW(TAG,
"Updating DHT12 failed!");
61 ESP_LOGW(TAG,
"DHT12 Checksum invalid!");
virtual void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message=nullptr)
void status_clear_warning()
void dump_config() override
float get_setup_priority() const override
sensor::Sensor * humidity_sensor_
sensor::Sensor * temperature_sensor_
bool read_data_(uint8_t *data)
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
void publish_state(float state)
Publish a new state to the front-end.
const float DATA
For components that import data from directly connected sensors like DHT.
Providing packet encoding functions for exchanging data with a remote host.