mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
negative values for all DHT22 variants (#6074)
Co-authored-by: Samuel Sieb <samuel@sieb.net>
This commit is contained in:
parent
343a8c063e
commit
aa04a3caaf
1 changed files with 6 additions and 2 deletions
|
@ -217,8 +217,12 @@ bool HOT IRAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, bool r
|
|||
uint16_t raw_humidity = (uint16_t(data[0] & 0xFF) << 8) | (data[1] & 0xFF);
|
||||
uint16_t raw_temperature = (uint16_t(data[2] & 0xFF) << 8) | (data[3] & 0xFF);
|
||||
|
||||
if (this->model_ != DHT_MODEL_DHT22_TYPE2 && (raw_temperature & 0x8000) != 0)
|
||||
if (raw_temperature & 0x8000) {
|
||||
if (!(raw_temperature & 0x4000))
|
||||
raw_temperature = ~(raw_temperature & 0x7FFF);
|
||||
} else if (raw_temperature & 0x800) {
|
||||
raw_temperature |= 0xf000;
|
||||
}
|
||||
|
||||
if (raw_temperature == 1 && raw_humidity == 10) {
|
||||
if (report_errors) {
|
||||
|
|
Loading…
Reference in a new issue