# libraries
from machine import Pin
from time import sleep
from dht import DHT22
# creating a DHT object
dht = DHT22(Pin(15))
while True:
# getting sensor readings
dht.measure()
temp = dht.temperature()
hum = dht.humidity()
# displaying values
print("Temperature: {}°C Humidity: {:.0f}% ".format(temp, hum))
# delay of 0.2 secs for the reading of the sensor
sleep(0.2)