#Hardware connection used:
#DHT22 Vcc Pin to 3.3V
#DHT22 SDA Pin to GPIO 14
#10k ohm pull-up resistor
#DHT22 GND Pin to GND
#modules
from machine import Pin
from time import sleep
from dht import DHT22
#creating a DHT object
dht = DHT22(Pin(14))
led = Pin(0, Pin.OUT)
#continously get the sensor data
while True:
#getting sensor readings
dht.measure() #will measure humidity and temperature
temp = dht.temperature()
hum = dht.humidity()
#display the values of T an H to the consiole
print(f"Temperature: {temp} C Humidity: {hum}%")
#read the values from sensors every 2 seconds sleep (2)
if temp > 10:
led.on()
else:
led.off()