adafruit / Adafruit_CircuitPython_DHT

CircuitPython support for DHT11 and DHT22 type temperature/humidity devices
MIT License
179 stars 62 forks source link

Fix issue #32 #56

Closed yeyeto2788 closed 3 years ago

yeyeto2788 commented 3 years ago

This will finally fix the issue on other boards like the Orange Pi boards 😄

Fixes #32

yeyeto2788 commented 3 years ago

Fixes #32

Execution example:

Try number 1
A full buffer was not returned. Try again.

Try number 2
DHT sensor not found, check wiring

Try number 3
Checksum did not validate. Try again.

Try number 4
DHT sensor not found, check wiring

Try number 5
DHT sensor not found, check wiring

Try number 6
DHT sensor not found, check wiring

Try number 7
Got temp of: 21
And hum of: 22

Try number 8
DHT sensor not found, check wiring

Try number 9
A full buffer was not returned. Try again.

Try number 10
Got temp of: 21
And hum of: 22

Example script:

import time
import board
import adafruit_dht
dhtDevice = adafruit_dht.DHT11(board.PG7)

for try_number in range(1,11):
  print(f"Try number {try_number}")
  try:
    print(f"Got temp of: {dhtDevice.temperature}")
    print(f"And hum of: {dhtDevice.humidity}")
  except RuntimeError as e:
    print(e)
    time.sleep(2)
  else:
    time.sleep(2)
  print("\n")
ladyada commented 3 years ago

thanx!