diff --git a/DHT.cpp b/DHT.cpp index a48ac74..1f920a3 100644 --- a/DHT.cpp +++ b/DHT.cpp @@ -43,6 +43,12 @@ DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) { (void)count; // Workaround to avoid compiler warning. _pin = pin; _type = type; + // Adjust MIN_INTERVAL based on sensor type + if (_type == DHT11) { + _minInterval = 1000; // 1 second for DHT11 + } else { + _minInterval = 2000; // 2 seconds for other types + } #ifdef __AVR _bit = digitalPinToBitMask(pin); _port = digitalPinToPort(pin); diff --git a/DHT.h b/DHT.h index 95570e1..28e8e98 100644 --- a/DHT.h +++ b/DHT.h @@ -76,6 +76,7 @@ class DHT { private: uint8_t data[5]; uint8_t _pin, _type; + uint32_t _minInterval; // Minimum interval between reads #ifdef __AVR // Use direct GPIO access on an 8-bit AVR so keep track of the port and // bitmask for the digital pin connected to the DHT. Other platforms will use