Closed peiqinzhao closed 5 years ago
Hi @hbgxsm95! Thanks for pointing specific place in code. I don't remember, why I did so. Let me recheck and get back with the answer (or fix).
Sure. :)
According to test I made to remind what is wrong with calculation, I found that DHT11 always return zeros in decimal part of values:
2018-06-22T03:36:24.881 [ dht] DEBUG Decoded from DHTxx sensor: [33, 0, 27, 0, 60]
2018-06-22T03:36:24.882 [ main] INFO Sensor = DHT11: Temperature = 27*C, Humidity = 33% (retried 0 times)
In contrast DHT22 returns non-empty values:
2018-06-22T03:40:41.524 [ dht] DEBUG Decoded from DHTxx sensor: [1, 105, 1, 11, 118]
2018-06-22T03:40:41.524 [ main] INFO Sensor = DHT22: Temperature = 26.7*C, Humidity = 36.1% (retried 0 times)
Also, pay attention, that calculations for integer parts are different for DHT11 and DHT22. So, I would change the calculation for DHT11, but this will have no impact to final results. Possibly some modifications of DHT11 exist with non-zero decimal part, but I didn't see it.
Yes, I only use DHT11. After I add the decimal part in line 184, 185, the DHT11 return non-zero in decimal part of values.
Interesting! Could you send me how your 5 raw bytes looks like from debug output?
Since, I have DHT11 sensor which always return in second byte of humidity and temperature zero byte, I can't verify how to mix this amount with major byte, so will postpone this bug until the moment I get this equipment on hand.
Thanks!
Hi @hbgxsm95! If you have time for this, and may send me output like this one, I can finally accept decimal part calculation to the code:
2018-10-19T03:30:40.984 [ dht] DEBUG Pulses received from DHTxx sensor: [{0 11µs} {1 79µs} {0 55µs} {1 26µs} {0 50µs} {1 25µs} {0 57µs} {1 67µs} {0 57µs} {1 24µs} {0 52µs} {1 25µs} {0 54µs} {1 24µs} {0 54µs} {1 24µs} {0 54µs} {1 68µs} {0 54µs} {1 24µs} {0 57µs} {1 24µs} {0 52µs} {1 25µs} {0 51µs} {1 25µs} {0 56µs} {1 25µs} {0 53µs} {1 24µs} {0 54µs} {1 20µs} {0 58µs} {1 26µs} {0 53µs} {1 21µs} {0 54µs} {1 24µs} {0 54µs} {1 24µs} {0 54µs} {1 73µs} {0 54µs} {1 69µs} {0 54µs} {1 24µs} {0 54µs} {1 68µs} {0 58µs} {1 71µs} {0 52µs} {1 24µs} {0 54µs} {1 21µs} {0 57µs} {1 21µs} {0 58µs} {1 20µs} {0 58µs} {1 21µs} {0 54µs} {1 25µs} {0 51µs} {1 25µs} {0 54µs} {1 25µs} {0 53µs} {1 25µs} {0 54µs} {1 24µs} {0 54µs} {1 74µs} {0 53µs} {1 68µs} {0 53µs} {1 74µs} {0 52µs} {1 72µs} {0 52µs} {1 24µs} {0 55µs} {1 24µs} {0 54µs} {1 10ms}]
2018-10-19T03:30:40.984 [ dht] DEBUG CRCs verified: checksum from sensor(60) = calculated checksum(60=33+0+27+0)
2018-10-19T03:30:40.984 [ dht] DEBUG Decoded from DHTxx sensor: [33, 0, 27, 0, 60]
I still have no such DHT11 sensor, which produce non-zero decimal parts (as you can see in last line). Could you help me with output examples from your sensors?
I have the DHT11. Here's some output from my sensor. hopefully it helps:
2019-01-01T04:27:37.125 [ dht] DEBUG Pulses received from DHTxx sensor: [{0 39µs} {1 91µs} {0 52µs} {1 26µs} {0 51µs} {1 27µs} {0 51µs} {1 27µs} {0 50µs} {1 27µs} {0 51µs} {1 25µs} {0 53µs} {1 73µs} {0 52µs} {1 74µs} {0 52µs} {1 26µs} {0 51µs} {1 28µs} {0 49µs} {1 27µs} {0 52µs} {1 26µs} {0 50µs} {1 25µs} {0 53µs} {1 26µs} {0 62µs} {1 15µs} {0 61µs} {1 26µs} {0 52µs} {1 26µs} {0 51µs} {1 27µs} {0 49µs} {1 26µs} {0 52µs} {1 26µs} {0 51µs} {1 75µs} {0 51µs} {1 74µs} {0 52µs} {1 25µs} {0 53µs} {1 62µs} {0 64µs} {1 26µs} {0 50µs} {1 29µs} {0 49µs} {1 27µs} {0 52µs} {1 26µs} {0 50µs} {1 27µs} {0 50µs} {1 76µs} {0 50µs} {1 26µs} {0 51µs} {1 27µs} {0 49µs} {1 77µs} {0 49µs} {1 27µs} {0 53µs} {1 25µs} {0 50µs} {1 75µs} {0 51µs} {1 28µs} {0 50µs} {1 75µs} {0 51µs} {1 25µs} {0 53µs} {1 26µs} {0 49µs} {1 77µs} {0 50µs} {1 10ms}]
2019-01-01T04:27:37.128 [ dht] DEBUG CRCs verified: checksum from sensor(41) = calculated checksum(41=6+0+26+9)
2019-01-01T04:27:37.133 [ dht] DEBUG Decoded from DHTxx sensor: [6, 0, 26, 9, 41]
@justmiles, could you send me a link to the internet shop where you bought this sensor? DHT11 sensor that returns non-empty value in second byte is a complete surprise for me. I looked through a lot of source codes for Arduino, trying to find software which process second byte to extract decimal part of humidity and temperature from DHT11, without any success. Thanks for assistance!
@d2r2 my DHT11 came from this KOOKYE 16 in 1 Smart Home Sensor Modules bundle.
@justmiles, thanks for showing the sample! I will allow myself to assume, that this it not DHT11, though it looks like DHT11 :). If you have a time, try to specify DHT12 (DHT12 is almost the same, but support decimal part according to specification). To get DHT12 support, you need to pull newest release of go-dht.
The issue with presence of decimal part for humidity/temperature of some DHT11 sensors is resolved via changing sensor type to DHT12 sensor which was recently committed.
So this issue will be closed during month if no new objection emerge.
in the line 184, 185 of dht.go. why don't add the decimal part to the value? Based on the datasheet of DHT11, it supports the decimal part.