#less than 20 turn on heater
#20 to 25 turn off both
#beyond 25 turn off heat turn on ac
from machine import Pin
from time import sleep
import dht
sensor = dht.DHT22(Pin(16))
heater = Pin(23, Pin.OUT)
AC = Pin(22, Pin.OUT)
while True:
sleep(1)
sensor.measure()
temperature = sensor.temperature()
humidity = sensor.humidity()
temp_f = temperature * (9/5) + 32.0
print('temperature: ', temperature , '°c')
print('temperature: ' , temp_f , '°f')
print(' humidity;: ', humidity, "%")
if(temperature < 20):
heater.on()
AC.off()
elif(temperature >= 20 and temperature < 25 ):
heater.off()
AC.off()
else:
AC.on()
heater.off()