from machine import Pin
from time import sleep
from dht import DHT22
# if the sensor is DHT11, import DHT11 instead of DHT22
dht = DHT22 (Pin(15))
# continuously get sensor readings while the board has power
while True:
# getting sensor readings
dht.measure()
temp = dht.temperature()
hum = dht.humidity()
# displaying values to the console
print (f"Temperature: {temp}°C Humidity: {hum}% ")
sleep (2)