adafruit / adafruit/DHT-sensor-library
Incorrect frequency limit for DHT11
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Description
- Arduino board: Raspberry Pi Pico (RP2040 B1)
- Arduino IDE version (found in Arduino -> About Arduino menu): PlatformIO `earlephilhower` core
- List the steps to reproduce the problem below (if possible attach a sketch or
copy the sketch code in too):
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.
Contributor guide
Research direction
Start by locating DHT::read(...) and the MIN_INTERVAL constant in the library, then inspect how the sensor type is identified. Reproduce the looped dht.readHumidity() or dht.readTemperature() calls on a DHT11 and compare the read frequency with a DHT22. Done means DHT11 reads can reach 1Hz while the DHT22 limit remains 0.5Hz.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100