from machine import Pin
from utime import sleep
import dht
print("Hello, ESP32!")
d = dht.DHT22(Pin(4))
led_temp = Pin(15, Pin.OUT)
led_humidity = Pin(2, Pin.OUT)
def temp():
d.measure()
temp = d.temperature()
if temp > 30:
led_temp.on()
elif temp < 25:
led_temp.off()
def humidity():
d.measure()
humidity = d.humidity()
if humidity > 50:
led_humidity.on()
elif humidity < 51:
led_humidity.off()
def main():
temp()
humidity()
while True:
main()