From 53375d8d70ef285e343c15a82eaa69f1ff6364c0 Mon Sep 17 00:00:00 2001 From: Spacefish Date: Sat, 26 Dec 2015 22:32:34 +0100 Subject: [PATCH 1/2] Use MIN_INTERVAL define instead of hardcoded value --- DHT.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DHT.cpp b/DHT.cpp index 86ad91c..4807186 100644 --- a/DHT.cpp +++ b/DHT.cpp @@ -124,7 +124,7 @@ boolean DHT::read(bool force) { // Check if sensor was read less than two seconds ago and return early // to use last reading. uint32_t currenttime = millis(); - if (!force && ((currenttime - _lastreadtime) < 2000)) { + if (!force && ((currenttime - _lastreadtime) < MIN_INTERVAL)) { return _lastresult; // return last correct measurement } _lastreadtime = currenttime; From cad6977ba855ae31338d63b7e2abd49f4e0244e0 Mon Sep 17 00:00:00 2001 From: Timo Witte Date: Sun, 27 Dec 2015 02:47:09 +0100 Subject: [PATCH 2/2] fix initilization of _lastreadtime --- DHT.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DHT.cpp b/DHT.cpp index 4807186..5acbbc3 100644 --- a/DHT.cpp +++ b/DHT.cpp @@ -27,7 +27,7 @@ void DHT::begin(void) { // Using this value makes sure that millis() - lastreadtime will be // >= MIN_INTERVAL right away. Note that this assignment wraps around, // but so will the subtraction. - _lastreadtime = -MIN_INTERVAL; + _lastreadtime = millis()-MIN_INTERVAL; DEBUG_PRINT("Max clock cycles: "); DEBUG_PRINTLN(_maxcycles, DEC); }