Skip to content

Instantly share code, notes, and snippets.

@qbalsdon
Created July 12, 2024 11:01
Show Gist options
  • Save qbalsdon/391c3ce2d8e4b5e8c60c198da6f8dfbb to your computer and use it in GitHub Desktop.
Save qbalsdon/391c3ce2d8e4b5e8c60c198da6f8dfbb to your computer and use it in GitHub Desktop.
# Library:
# https://github.com/danjperron/PicoDHT22
from machine import Pin
from PicoDHT22 import PicoDHT22
import utime
dht_sensor=PicoDHT22(Pin(11,Pin.IN,Pin.PULL_UP),dht11=True)
while True:
temperature,humidity = dht_sensor.read()
if temperature is None:
print(" sensor error")
else:
print("{}'C {}%".format(temperature, humidity))
#DHT22 not responsive if delay to short
utime.sleep_ms(500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment