from machine import Pin
from time import sleep
from dht import DHT22
temp_pin = 4
dht = DHT22(Pin(temp_pin))
def read_temp_and_humidity():
while True:
dht.measure()
temp_celsius = dht.temperature()
temp_fahrenheit = (temp_celsius * 9/5) + 32
humidity = dht.humidity()
print(f"Temperature: {temp_celsius}°C, {temp_fahrenheit}°F, Humidity: {humidity}%")
sleep(2)
read_temp_and_humidity()