From 28f9205701d2da5f75a54f49f7b2235bf7beff73 Mon Sep 17 00:00:00 2001 From: destroyedlolo Date: Sat, 24 Mar 2018 13:46:19 +0100 Subject: [PATCH] Correct OW code in case of DHT reading error --- examples/DS18B20_DHT22/DS18B20_DHT22.ino | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/DS18B20_DHT22/DS18B20_DHT22.ino b/examples/DS18B20_DHT22/DS18B20_DHT22.ino index 9497d39..cb4f752 100644 --- a/examples/DS18B20_DHT22/DS18B20_DHT22.ino +++ b/examples/DS18B20_DHT22/DS18B20_DHT22.ino @@ -92,6 +92,8 @@ void setup(){ void loop(){ delay(10); + // No need to have a local copy of "state" as we are looking + // for only one value if(state == DeviceState::CONVERTING){ // start conversion float temperature = 0; float humidite = 0; @@ -103,10 +105,9 @@ void loop(){ Serial.println(err); #endif temperature = 85; - } else { + } else setTemperature( temperature ); - state = DeviceState::TEMPERATUREREADY; - OWSlave.beginWriteBit(1, true); - } + state = DeviceState::TEMPERATUREREADY; + OWSlave.beginWriteBit(1, true); } }