-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with widely out readings #102
Comments
Full disclosure .... at some point I had the pinout wrong (order is data; V; Gnd on the KY-015). Its possible I've damaged the sensor, but then I'd expect to get no readings rather than strange ones). Unfortunately I don't have another of these devices to swap with. |
Thanks for reporting this, It might be that the KY-015 is not 100% compatible too. |
The link shows some code which is very opportunistic in the timing. They hardcode delays where I know from experience that there is some spread in the timing if you compare actual sensors. Can you run the dhtnew_pulse_diag_ext.ino sketch and post its output? |
mmm, anything is possible, the internal processor might still work but the "physics" part might be fried. |
Thanks Rob https://oshwlab.com/adrirobot/ky-015-temperature-and-humidity-sensor-module has the correct circuit diagram - dead simple, just one pull-up on the data line. The board comes from a cheap collection of all the Arduino sensors on AliExpress, no data sheet or confirmation - it is specified as being KY-015 but I can't see how to tell as visually the DHT11 and DHT22 look the same (mine is blue, but they both appear to come in both colors). I thought it was a decimal point issue, but current figures from the DHT are 2407.1, 487.2, while my SHT is reporting 75% and 24C Will add output of dhtnew_pulse_diag_ext.ino to next comment. (Minor suggestion: rename one of the examples as something like dhtnew_simple, it was hard to figure out which was a standard example to copy from and which were, like this, your tests. ) |
|
Only change I made to the sketch was to set the pin D2, and serial speed, and note that its a ESP8266, not an ESP32.
|
Thanks for the log data. Will look at it tomorrow as it is rather late here. The DHT11 is often blue and the DHT22 light gray, |
Out of curiousity ..... And my temp/humidity (cheap consumer) device is reporting 79% humidity 21C which is close to the SHT. I've also tried switching voltage (3.3V vs 5V); switching to a newer version of the D1 Mini; and switching which data pin. Whichever sketch I'm using the results stay consistent with those changes. |
My DHT is blue. |
Had a quick look and the decoding could be... Humidity is 5B03 that could be integer byte and a decimal byte. Makes 91.3% Hum. Temperature is 0x1404 => 20.4C To be continued... |
That matches the info in the link and gives something to work with. |
Can you add a line that states Dht.setType(11); In setup() at least before the first dht.read() This should give better readings. I'm thinking how to improve the auto detection to include KY-015. (Updated) |
Q: do you know if the KY015 can do negative temperatures (below 0 C or 32. F) |
I'm confused - or maybe you are :-) |
The library tries to recognize the type of the sensor. It uses the wakeuptime which is ~18 milliseconds for a DHT11 and ~1 ms for DHT22. The KY015 (board) awakes as fast as the DHT22 that is why the library thinks it is a DHT22 and consequently fails to convert the bits properly to T and H. The encoding of the bits is DHT11 alike. The DHT11 does not do negative temperatures, and I dont know if the KY015 does. So my guess is that the KY015 uses actually a follow up chip of the DHT11 (lets name it DHT15) that uses the same code but has internally a faster processor or optimized code. So far my confusion:) Did you try adding the setType(11); line? I will add examples as requested |
The library tries to recognize the type of the sensor. It uses the wakeuptime which is ~18 milliseconds for a DHT11 and ~1 ms for DHT22. The KY015 awakes as fast as the DHT22 that is why the library thinks it is a DHT22 and consequently fails to convert the bits properly to T and H. The encoding of the bits is DHT11 alike. The DHT11 does not do negative temperatures, and I dont know if the KY015 does. So my guess is that the KY015 uses actually a follow up chip of the DHT11 (lets name it DHT15) that uses the same code but has internally a faster processor or optimized code. So far my confusion:) Did you try adding the setType(11); line? I will add examples as requested |
I have to rethink the recognition algorithm to include the new Insights. |
OK interesting - KY-015 is supposed to be a DHT11 but its a china clone, so who knows what they used ! And maybe there is a clone of the DHT11 out there that wakes up faster. I'm guessing the DHT22 and DHT11 use the same checksum algorithm so while the data is different you cant use a passed checksum as a way to know which type it is. I added the setType(11) line, and that works to get good data now. |
@mitra42 The recognition algorithm will take a few days. |
And my own code ... to read the sensor and send over MQTT at https://github.com/mitra42/frugal-iot/blob/main/sensor_dht.cpp is working as well thanks |
Sure - happy to help test, I've checked out the library, let me know when you want a test done The examples look good - about the right level of complexity I think - at least if I was looking to understand how to use a library it would be about right. |
Add a first version of the recognition of the KY-015 as DHT11 to develop. (it was raining so I had some time) If you have time please try the latest develop branch to see if it recognizes the KY015 as type 11 and still works for you. In the end it is a simple test, Made a note in the readme that in the future I could read the bits and convert them to see which conversion is needed. |
Nice solution - and should be solid as it would take both bad data that successfully passed CRC to get the wrong result. I ran the dhtnew_simple example and it worked first time - EXCEPT the very first result had a bad value ...
|
Oh - and there was a warning on compilation
|
Thanks for the feedback, need to look at that first read. Its too late to fix now (netherlands ~ 22:30) so an update will come tomorrow. Thanks for testing! |
Happy to - and by the way, I wouldn't presume this is specific to a KY015. KY015 is a generic open-source board design for a peripheral (used in Arduino projects) - that supposedly uses a DHT11. I'm guessing this is a new chip (clone?) that this supplier is using, which means it will probably turn up elsewhere labeled DHT11. I picked up one of these packs https://www.aliexpress.com/item/1005006222476183.html (45 sensors for USD18) just to have a range of sensors to experiment with, so I have no real visibility of the source of the components they used. |
That is a bug, should be += |
Did some background search to check the 3% humidity test in the code Desert air still has about 20% humidity, so the 3% used in the code seems pretty safe. The North and South Poles can have an extreme low humidity however that is not a place to use a DHT11 which cannot do below freezing. So pretty safe. Sahara |
@mitra42
Thanks, |
Correct - output is now ...
So first read is, in this case a fail - which is fine. |
Thanks for testing! If there are no other issues, I will merge the develop branch later today. |
No issues from my side |
Released 0.5.1 |
I'm seeing problems with consistently wrong readings and not sure if I'm doing something wrong or what.
My setup is a D1 mini (early version) connected to a KY-015 which is supposed to be a DHT11
https://arduinomodules.info/ky-015-temperature-humidity-sensor-module/
I've got it hooked to 5V but get the same results at 3.3V
I'm currently hooked up to pin D2 but I get the same results on pin D1
I couldn't find a canonical - simplest possible - example - so I'm using "array". The unconnected sensors just show 999's as I'd expect but the D2 is showing ...
20:48:04.094 -> 1, Waiting for read, 2048.5, 537.8, 4, 22
Which I take as a humidity of 2048% and temperature of 537C, and that the device is actually a DHT22
It seems consistent - I've tried some of the other examples and get similar results.
If I breath on the sensor, as expected temperature and humidity go up.
The text was updated successfully, but these errors were encountered: