Skip to content

Commit

Permalink
Update hdc2010.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
optimusprimespace committed Oct 7, 2024
1 parent a27a8dc commit 013ada4
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions esphome/components/hdc2010/hdc2010.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ void HDC2010Component::update() {

if (this->temperature_sensor_ != nullptr) {
float temp = this->read_temp();
this->temperature_->publish_state(temp);
this->temperature_sensor_->publish_state(temp);
ESP_LOGD(TAG, "Got temperature=%.1f°C", temp);
}

if (this->humidity_sensor_ != nullptr) {
float humidity = this->read_humidity();
this->humidity_->publish_state(humidity);
this->humidity_sensor_->publish_state(humidity);
ESP_LOGD(TAG, "Got humidity=%.1f%%", humidity);
}
}
Expand All @@ -100,17 +100,6 @@ float HDC2010Component::read_temp() {
return (float) temp * 0.0025177f - 40.0f;
}

float HDC2010Component::read_temp() {
uint8_t byte[2];
uint16_t temp;

this->read_register(HDC2010_CMD_TEMPERATURE_LOW, &byte[0], 1);
this->read_register(HDC2010_CMD_TEMPERATURE_HIGH, &byte[1], 1);

temp = (unsigned int) byte[1] << 8 | byte[0];
return (float) temp * 0.0025177f - 40.0f;
}

float HDC2010Component::read_humidity() {
uint8_t byte[2];
uint16_t humidity;
Expand All @@ -122,6 +111,6 @@ float HDC2010Component::read_humidity() {
return (float) humidity * 0.001525879f;
}

float HDC2010Component::get_setup_priority() const { return this->setup_priority::DATA; }
float HDC2010Component::get_setup_priority() const { return setup_priority::DATA; }
} // namespace hdc2010
} // namespace esphome

0 comments on commit 013ada4

Please sign in to comment.