from machine import Pin, ADC, Timer
import dht
from time import sleep
ldr = ADC(Pin(34))
ldr.atten(ADC.ATTN_11DB)
dht_sensor = dht.DHT22(Pin(14))
led = Pin(15, Pin.OUT)
led2 = Pin(2, Pin.OUT)
light_threshold = 1000
temp_threshold = 30
count = 0
while True:
light_value = ldr.read()
dht_sensor.measure()
temperature = dht_sensor.temperature()
if light_value >= light_threshold:
led.value(1)
else:
led.value(0)
if temperature > temp_threshold:
print("HIGH TEMPERATURE, AC is on")
led2.value(1)
else:
print("low temperature")
led2.value(0)
sleep(1)
count = count + 1