erikdelange / WiPy-2.0-DHT22

Measure temperature and humidity using the DHT22 and a WiPy 2.0
4 stars 1 forks source link

Persistent ReadError on subsequent calls to trigger() #1

Closed mhermans closed 6 years ago

mhermans commented 6 years ago

Thank you for the library and documented example.

After the first call to trigger(), I get a successful status and temperature/humidity values. However, subsequent calls to trigger() result in a ReadError.

If I re-initialise the device-object with

dht = dht22.device(Pin.exp_board.G22)

the first call to dht.trigger() again succeeds, the rest fails.

I'm not sure what is causing this, or if I'm perhaps using the library wrong.

MicroPython v1.8.6-849-baa8c33 on 2018-01-29; LoPy with ESP32

erikdelange commented 6 years ago

Thanks for spotting this. There was an error in the dht22 class. After the call to pycom.pulses_get() the SDA pin had to be reinitialized via self.pin.init(Pin.OPEN_DRAIN). This is now adjusted. The example in file dht22.py now does 5 subsequent reads to show this.