adafruit / DHT-sensor-library

Arduino library for DHT11, DHT22, etc Temperature & Humidity Sensors
https://learn.adafruit.com/dht
MIT License
1.99k stars 1.42k forks source link

Incorrect frequency limit for DHT11 #206

Open cryptoAlgorithm opened 1 year ago

cryptoAlgorithm commented 1 year ago
  1. Read values from the sensor in a loop: dht.readHumidity() or dht.readTemperature()
  2. Observe that values do not change at a frequency higher than 0.5Hz

It appears that this is due to an artificial ratelimit imposed by the DHT::read(...) method. Specifically, MIN_INTERVAL is hardcoded to 2000 for all types of sensors, which I assume is due to the DHT22's maximum read frequency of 0.5Hz. However, other sensors supported by this library, such as the DHT11, can read at a higher rate of 1Hz, so this value should instead be set based on the sensor type.