Closed BrammyS closed 4 years ago
I ran it with a small python script as well. And it resulted in the correct values.
I was running a Dht11 sensor before this, and i never had any problems with it. Except with the 2°C inaccuracy. :P
I was running a Dht11 sensor before this, and i never had any problems with it.
So when you say ya were running it before, do you mean with python or with .net core? If you were doing it with .net core and it was working correctly, did you recompile or updated the nuget package to get a newer version?
cc: @Ellerbach @ZhangGaoxing as FYI.
@joperezr The Dht11 was almost running on the exact same code. Just replace the
using var dht = new Dht22(26);
With
using var dht = new Dht11(26);
I just remebered that i updated to .net core 3.1
as well. So the Dht11 was running on .net core 3.0
and the Dht22 is running on .net core 3.1
. You can see all the changes here.
I can try running the Dht11 on .net core 3.1
as well to see if the same thing will happen.
Sustained, similar bug. You can see the code here: https://github.com/fomenkodmitry/NetCore-raspberrypi4-dht22 Platform: Rasberry pi 4 model b, net core 3.1, dht22
python3 ../../humidity.py
Temp=26.3*C Humidity=33.4%
Temp=26.3*C Humidity=33.9%
Temp=26.3*C Humidity=33.9%
dotnet run
Hello DHT!
Temperature: NaN°C, Humidity: NaN%
Temperature: NaN°C, Humidity: NaN%
Temperature: NaN°C, Humidity: NaN%
Temperature: 1.7°C, Humidity: 33.2%
Temperature: 1.7°C, Humidity: 33.3%
@fomenkodmitry and @BramEsendam, you are right, there was a mistake. I found some time to dig into the code and found the problem. Line 32 in the Dht222.cs file should be:
var temp = ((readBuff[2] & 0x7F) * 256 + readBuff[3]) * 0.1;
@joperezr, will make a PR asap.
I've merged that PR so hopefully the results will be fine now. I'll go ahead and close this issue assuming it does, but please feel free to reopen if that is not the case.
The temperature output dropped to to 1°C when the real temperature got above 26°C.
Steps to reproduce
Expected behavior
Output: Temperature: 26.0 °C, 'Humidity: 36.1 %
Actual behavior
Output: Temperature: 1.0 °C, 'Humidity: 36.1 %
Versions used
Add following information:
Version: 3.1.1 Commit: a1388f194c
Version: 3.1.1 Commit: a1388f194c
System.Device.Gpio
package:1.0.0
Iot.Device.Bindings
package:1.0.0