8 static const char *
const TAG =
"hyt271";
10 static const uint8_t HYT271_ADDRESS = 0x28;
13 ESP_LOGCONFIG(TAG,
"HYT271:");
15 LOG_UPDATE_INTERVAL(
this);
17 LOG_SENSOR(
" ",
"Humidity", this->
humidity_);
20 uint8_t raw_data[4] = {0, 0, 0, 0};
24 ESP_LOGE(TAG,
"Communication with HYT271 failed! => Ask new values");
31 ESP_LOGE(TAG,
"Communication with HYT271 failed! => Read values");
34 uint16_t raw_temperature = ((raw_data[2] << 8) | raw_data[3]) >> 2;
35 uint16_t raw_humidity = ((raw_data[0] & 0x3F) << 8) | raw_data[1];
37 float temperature = ((float(raw_temperature)) * (165.0f / 16383.0f)) - 40.0f;
38 float humidity = (float(raw_humidity)) * (100.0f / 16383.0f);
40 ESP_LOGD(TAG,
"Got Temperature=%.1f°C Humidity=%.1f%%", temperature, humidity);
sensor::Sensor * humidity_
const float DATA
For components that import data from directly connected sensors like DHT.
void status_set_warning(const char *message="unspecified")
ErrorCode read(uint8_t *data, size_t len)
reads an array of bytes from the device using an I2CBus
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
ErrorCode write(const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a device using an I2CBus
No error found during execution of method.
void status_clear_warning()
void dump_config() override
void publish_state(float state)
Publish a new state to the front-end.
void update() override
Update the sensor values (temperature+humidity).
Implementation of SPI Controller mode.
float get_setup_priority() const override
sensor::Sensor * temperature_