Open davemacrae opened 3 years ago
Hi,
On investigation and reflection, I don't think Remote GPIO will work with the DHT sensors. If it does work, it would be erratic and unreliable and in all probability return incorrect readings at best.
DHT sensors communicate data using a time-based protocol that requires microsecond accuracy. I'd expect latency added by the network will interfere with the timing causing the library to time out.
Further to this, part of the protocol is a timing-based "handshake". Latency that interferes with this means the library never receives the expected handshake and thus times out. Increasing the timeout will not help here since the library is not waiting for communication to finish, it's waiting for (and not receiving) the handshake timing signal.
Given this situation, the pi
parameter should be removed from the constructor.
Use an API based approach or something similar to remotely access DHT data on a remote Pi. Network Zero (https://networkzero.readthedocs.io) is handy for quick PoC and small projects.
Thanks for the feedback Gary.
I resolved my problem by just reading the devices locally and using Prometheus to gather the data from the devices to a central point.
Dave
I have two DHT22 sensors attached to a Pi Zero.
Sample Code:
Running the above on the Pi Zero W pretty much always results in two successful readings. However, if I attempt to run the code from another device on my network (in this case a Pi 4), then the attempt to read the sensors will often (pretty much always) results in a Timeout.
The Pi Zero is connected to my network via inbuilt WiFi.
or
Any ideas how I can resolve this?
Thanks
Dave