I just wrote this function for my printer enclosure, which has 2 DHT22s installed.
Works almost every time, sometimes it runs into a timeout, but that's likely due to long wires and the very strict timing requirements of those sensors. Communication protocol from the sensor datasheet, algorithm entirely written by me.
Tested on a Raspberry Pi 3 Model B, should work on all variants. Don't forget the resistor (4.7k to 10k) between Data and VCC if your sensor hasn't one built in!
I just wrote this function for my printer enclosure, which has 2 DHT22s installed. Works almost every time, sometimes it runs into a timeout, but that's likely due to long wires and the very strict timing requirements of those sensors. Communication protocol from the sensor datasheet, algorithm entirely written by me. Tested on a Raspberry Pi 3 Model B, should work on all variants. Don't forget the resistor (4.7k to 10k) between Data and VCC if your sensor hasn't one built in!