Closed Woselko closed 2 months ago
Hi @Woselko
Thanks for the report. This is likely a timing issue. The DHT read code uses a busy loop for reading the individual bits, much like your implementation. I'm assuming the maximum loopcount (here) is just too small for the RPI5, because that CPU is significantly faster than the RPI4.
I do like your implementation with the state machine. Maybe we should switch to that instead.
Hi, thanks for your reply! Here is what I tried (just to test in the fastest way this _loopcount field):
using (Dht11 dht11 = new Dht11(pin, PinNumberingScheme.Logical, gpio))
{
Type myClassType = typeof(DhtBase);
FieldInfo privateIntField = myClassType.GetField("_loopCount", BindingFlags.NonPublic | BindingFlags.Instance);
privateIntField.SetValue(dht11, (uint)20000);
Dht(dht11);
}
of course parameter was changed as on the screen
But in won't help. I have tested from 10000 to 160000 by increasing every 5000
Is there anything more that I can check?
I guess this needs some logging. It's probably the easiest if you check out the source and ad logs to the Read method to find out where it fails.
I don't have a Pi5 yet, so I cannot try.
Ok, I will deliver it in several days. Thanks
Has there been any developments on this issue?
Hi @Woselko, As @pgrawehr wrote, the DHT11/DHT22 are very time sensitive devices and therefore they are not a great choice to verify whether the GPIOs are working correctly. If your goal is to validate the GPIO working correctly on the RPi5, I would strongly suggest to test non time-sensitive devices first.
Generally speaking, I would personally recommend to drive DHTxx devices using a microcontroller. On the RPi you can certainly use them, but you should expect a number of communication errors due to the timings (Linux is not a realtime OS, .NET code gets interrupted from the GC, etc.).
I kindly ask you to verify whether your issue depends on the GPIO or just depends on the DHTxx devices. Thank you
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.
Bug description I have the Raspberry Pi 5 version with 64bit Raspbian version . I'm trying to read temperature from with DHT11 sensor with this example: Link: https://github.com/dotnet/iot/tree/main/src/devices/Dhtxx Code:
I have no succesfull read at all. I've tried to add something like that:
ALSO
But nothing helps me :(.
What is more I know that I have connected everything correctly because my own implementation for DHT11 works Link: https://github.com/Woselko/DotnetRaspBerryPi5Patterns/blob/main/DHT11SensorApp/Dht11Reader.cs Code (Working):
This code was rewritten from another C/C++ example and it works 100%. Why is that? Do we need to implement everything from level zero? Is this somehow connected with my environment or dotnet version? I run this code with net7.0 and net8.0 results are the same.
Im sure that I have correct and working one wire DHT11 sensor. Also I was trying to run examples for other devices like DHT22, Bh1750fvi and many others.
If you need any additional information, I will provide it quickly
I will be grateful for any help from you. I will appreciate it very much.
Expected behavior bool success = dht.TryReadHumidity(out humidity) && dht.TryReadTemperature(out temperature); should return succes
Actual behavior bool success = dht.TryReadHumidity(out humidity) && dht.TryReadTemperature(out temperature); always return false
Versions used -woselko@raspberrypi:~ $ dotnet --version 8.0.100
System.Device.Gpio
package 3.1.0Iot.Device.Bindings
package 3.1.0