stianeikeland / go-rpio

:electric_plug: Raspberry Pi GPIO library for go-lang
MIT License
2.2k stars 221 forks source link

DHT22/AM2302 example #81

Open TazerReloaded opened 2 years ago

TazerReloaded commented 2 years ago

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!