danjperron / PicoDHT22

Micropython DHT22 class using PIO
MIT License
49 stars 12 forks source link

Update DHT22.py to attach DHT11 power pin to GPIO without sensor error #1

Closed allyourcodearebelongtous closed 3 years ago

allyourcodearebelongtous commented 3 years ago

Thx for your lib, great work.

I encountered a little problem when I decided to power off the sensor after reading the values in DHT22.read_array(). Adding

if self.powerPin is not None:
    self.powerPin.value(0)

just before returning the value ended up in giving me a "sensor error" all the time.

I liked the approach to power off the sensor via a GPIO pin. However, delaying the start of the state machine by 100ms not enough, so I additionally increased the value from 100 to 200ms. Now the DHT11 responds correctly when trying the first time.

danjperron commented 3 years ago

Thanks! Done!