Update hdc2010.cpp

This commit is contained in:
optimusprimespace 2024-05-17 14:28:00 -04:00
parent c6c03b5599
commit d75745ee9f

View file

@ -1,6 +1,6 @@
#include "hdc2010.h"
#include "esphome/core/log.h"
#include "esphome/core/hal.h" #include "esphome/core/hal.h"
#include "esphome/core/log.h"
#include "hdc2010.h"
// https://github.com/vigsterkr/homebridge-hdc2010/blob/main/src/hdc2010.js // https://github.com/vigsterkr/homebridge-hdc2010/blob/main/src/hdc2010.js
// https://github.com/lime-labs/HDC2080-Arduino/blob/master/src/HDC2080.cpp // https://github.com/lime-labs/HDC2080-Arduino/blob/master/src/HDC2080.cpp
namespace esphome { namespace esphome {
@ -68,23 +68,23 @@ void HDC2010Component::dump_config() {
} }
void HDC2010Component::update() { void HDC2010Component::update() {
uint8_t tempLow, tempHigh, humidLow, humidHigh; // uint8_t tempLow, tempHigh, humidLow, humidHigh;
// Trigger measurement // Trigger measurement
uint8_t configContents; // uint8_t configContents;
read_register(CONFIG, &configContents, 1); // read_register(CONFIG, &configContents, 1);
configContents |= 0x01; // configContents |= 0x01;
this->write_bytes(CONFIG, &configContents, 1); // this->write_bytes(CONFIG, &configContents, 1);
delayMicroseconds(1000); // 1ms delay after triggering the sample // delayMicroseconds(1000); // 1ms delay after triggering the sample
if (!read_register(HDC2010_CMD_TEMPERATURE_LOW, &tempLow, 1) || // if (!read_register(HDC2010_CMD_TEMPERATURE_LOW, &tempLow, 1) ||
!read_register(HDC2010_CMD_TEMPERATURE_HIGH, &tempHigh, 1) || // !read_register(HDC2010_CMD_TEMPERATURE_HIGH, &tempHigh, 1) ||
!read_register(HDC2010_CMD_HUMIDITY_LOW, &humidLow, 1) || // !read_register(HDC2010_CMD_HUMIDITY_LOW, &humidLow, 1) ||
!read_register(HDC2010_CMD_HUMIDITY_HIGH, &humidHigh, 1)) { // !read_register(HDC2010_CMD_HUMIDITY_HIGH, &humidHigh, 1)) {
this->status_set_warning(); // this->status_set_warning();
return; // return;
} // }
float temp = readTemp(); float temp = readTemp();
float humidity = readHumidity(); float humidity = readHumidity();