#Project Objectives
#Read temperature and humidity values from the DHT22 sensor
#Display the sensor readings in the console
#
#Hardware connections used:
#DHT22 Vcc Pin to 3.3V
#1k 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)
#continuously get the sensor data
while True:
#getting sensor readings
dht.measure()
temp = dht.temperature()
hum = dht.humidity()
#display the values of T and H to the console
print(f"Temperature: {temp} C Humidity: {hum}%")
#read the values from sensor every 2 secs
sleep(2)
if temp>25:
led.on()
else:
led.off()