import random
import dht
from machine import Pin, PWM
from utime import sleep
sensor = dht.DHT22(Pin(2))
led1 = Pin(0, Pin.OUT)
speak = PWM(Pin(2))
speak.freq(500)
while True:
led1.off()
speak.duty_u16(0)
sensor.measure()
temp = random.randint(20, 60)
hum = sensor.humidity()
print(f"Temperature: {temp}, humidity: {hum}")
if temp > 40:
led1.on()
speak.duty_u16(1000)
sleep(2)