Skip to content

Commit dc71b00

Browse files
Merge pull request #52 from Spacefish/master
Use MIN_INTERVAL define instead of hardcoded value
2 parents 562a487 + cad6977 commit dc71b00

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

DHT.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void DHT::begin(void) {
2727
// Using this value makes sure that millis() - lastreadtime will be
2828
// >= MIN_INTERVAL right away. Note that this assignment wraps around,
2929
// but so will the subtraction.
30-
_lastreadtime = -MIN_INTERVAL;
30+
_lastreadtime = millis()-MIN_INTERVAL;
3131
DEBUG_PRINT("Max clock cycles: "); DEBUG_PRINTLN(_maxcycles, DEC);
3232
}
3333

@@ -124,7 +124,7 @@ boolean DHT::read(bool force) {
124124
// Check if sensor was read less than two seconds ago and return early
125125
// to use last reading.
126126
uint32_t currenttime = millis();
127-
if (!force && ((currenttime - _lastreadtime) < 2000)) {
127+
if (!force && ((currenttime - _lastreadtime) < MIN_INTERVAL)) {
128128
return _lastresult; // return last correct measurement
129129
}
130130
_lastreadtime = currenttime;

0 commit comments

Comments
 (0)