import dht
import machine as m
from time import sleep
led = m.Pin(16, m.Pin.OUT)
sensor = dht.DHT22(m.Pin(17))
pot = m.ADC(m.Pin(26, m.Pin.IN))
while True:
sensor.measure()
temp = sensor.temperature()
hum = sensor.humidity()
# divide the pot's max value (4095) by 34.125 to make it 120
# then -40 to make 80 the max value, and -40 the minimum
thres = (pot.read() / 34.125) - 40
if temp > thres:
led.value(1)
else:
led.value(0)
print(f"Threshold: {thres:.2}°C; Temp: {temp}°C; Humidity: {hum}%")
sleep(1)