From 82eca13d7b84a8972836b078531c1236bdd991bc Mon Sep 17 00:00:00 2001 From: besteru <69540218+besteru@users.noreply.github.com> Date: Mon, 20 Sep 2021 10:14:44 +0300 Subject: [PATCH] Fix error reporting for DHT bit read loop (#2344) --- esphome/components/dht/dht.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esphome/components/dht/dht.cpp b/esphome/components/dht/dht.cpp index a7f5747d68..734dde20a8 100644 --- a/esphome/components/dht/dht.cpp +++ b/esphome/components/dht/dht.cpp @@ -122,6 +122,8 @@ bool HOT ICACHE_RAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, break; } } + if (error_code != 0) + break; start_time = micros(); uint32_t end_time = start_time; @@ -136,6 +138,8 @@ bool HOT ICACHE_RAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, break; } } + if (error_code != 0) + break; if (i < 0) continue;