8static const char *
const TAG =
"hdc1080";
10static const uint8_t HDC1080_CMD_CONFIGURATION = 0x02;
11static const uint8_t HDC1080_CMD_TEMPERATURE = 0x00;
12static const uint8_t HDC1080_CMD_HUMIDITY = 0x01;
15 const uint8_t config[2] = {0x00, 0x00};
19 ESP_LOGW(TAG,
"Failed to configure HDC1080");
26 ESP_LOGCONFIG(TAG,
"HDC1080:");
29 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
31 LOG_UPDATE_INTERVAL(
this);
33 LOG_SENSOR(
" ",
"Humidity", this->
humidity_);
48 uint16_t raw_temperature;
49 if (this->
read(
reinterpret_cast<uint8_t *
>(&raw_temperature), 2) !=
i2c::ERROR_OK) {
56 float temperature = raw_temperature * 0.0025177f - 40.0f;
66 uint16_t raw_humidity;
74 float humidity = raw_humidity * 0.001525879f;
void status_set_warning(const char *message=nullptr)
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.
sensor::Sensor * temperature_
sensor::Sensor * humidity_
void dump_config() override
ErrorCode write_register(uint8_t a_register, const uint8_t *data, size_t len) const
writes an array of bytes to a specific register in the I²C device
ErrorCode write(const uint8_t *data, size_t len) const
writes an array of bytes to a device using an I2CBus
ErrorCode read(uint8_t *data, size_t len) const
reads an array of bytes from the device using an I2CBus
void publish_state(float state)
Publish a new state to the front-end.
uint16_t i2ctohs(uint16_t i2cshort)
@ ERROR_OK
No error found during execution of method.
Providing packet encoding functions for exchanging data with a remote host.