import time
from machine import Pin, ADC
import math
led1= Pin (11,Pin.OUT)
led2 = Pin (17,Pin.OUT)
temp=ADC(28)
light= ADC(26)
while True:
analog_temp_val = temp.read_u16()
BETA = 3950
GAMMA = 0.7
RL10 = 50
celsius = 1 / (math.log(1 / (65535 / analog_temp_val - 1)) / BETA + 1.0 / 298.15) - 273.15
print (celsius)
analog_light = light.read_u16()
voltage = analog_light / 65535 * 5
resistance = 2000 * voltage / (1 - voltage / 5)
lux = pow(RL10 * 1e3 * pow(10, GAMMA) / resistance, (1 / GAMMA))
print(lux)
if lux < 500 :
led1.on()
else:
led1.off()
if celsius > 25 :
led2.on()
else:
led2.off()