adafruit / adafruit/DHT-sensor-library
Feature request: changing sensor type
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Description
I have a large sketch, which is used either with DHT11 or DHT22. I am wondering if it is possible to let automatically find the right sensor type.
When the sensor type is wrongly set up, the readout fails or gives non-sense values.
In that case, I would try to redefine the type of sensor and try the readout again.
This will allow me to have a single program for all my devices (a sort of autodetect for the sensor type).
In my tests, I was not able to start the readout again after recreating the object with the new sensor type.
I have this initialization in the header:
`DHT_Unified dht(2, DHT22);`
I hade this in the setup:
`dht.begin();`
In the loop, once the failed readouts are more than 10 without any good one, the program executes:
```
DHT_Unified dht(2, DHT11);
dht.begin();
```
My approach is not working because I continue to fave failed readouts. It seems that the sensor type definition cannot be changed on the run.
Contributor guide
Research direction
No files or tests are named. Start by tracing DHT_Unified construction and begin() from setup(), then reproduce the failed type change from loop() with DHT11 and DHT22. Done should be defined as a supported way to identify or reconfigure the sensor and obtain successful readouts for both types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- arduino, cpp
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100