8 static const char *
const TAG =
"hdc1080";
10 static const uint8_t HDC1080_ADDRESS = 0x40;
11 static const uint8_t HDC1080_CMD_CONFIGURATION = 0x02;
12 static const uint8_t HDC1080_CMD_TEMPERATURE = 0x00;
13 static const uint8_t HDC1080_CMD_HUMIDITY = 0x01;
16 ESP_LOGCONFIG(TAG,
"Setting up HDC1080...");
18 const uint8_t data[2] = {
23 if (!this->
write_bytes(HDC1080_CMD_CONFIGURATION, data, 2)) {
25 ESP_LOGW(TAG,
"HDC1080 initial config instruction error");
31 ESP_LOGCONFIG(TAG,
"HDC1080:");
34 ESP_LOGE(TAG,
"Communication with HDC1080 failed!");
36 LOG_UPDATE_INTERVAL(
this);
38 LOG_SENSOR(
" ",
"Humidity", this->
humidity_);
52 float temp = raw_temp * 0.0025177f - 40.0f;
55 uint16_t raw_humidity;
66 float humidity = raw_humidity * 0.001525879f;
69 ESP_LOGD(TAG,
"Got temperature=%.1f°C humidity=%.1f%%", temp, humidity);
void update() override
Retrieve the latest sensor values. This operation takes approximately 16ms.
const float DATA
For components that import data from directly connected sensors like DHT.
void dump_config() override
uint16_t i2ctohs(uint16_t i2cshort)
sensor::Sensor * temperature_
sensor::Sensor * humidity_
void setup() override
Setup the sensor and check for connection.
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
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 publish_state(float state)
Publish a new state to the front-end.
float get_setup_priority() const override
Implementation of SPI Controller mode.
void IRAM_ATTR HOT delay(uint32_t ms)
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len, bool stop=true)