adafruit/DHT-sensor-library

Feature request: changing sensor type

ilmanowar opened this issue · 0 comments

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.