import machine
import math
import utime
BETA = 3950
R1 = 10000
V_REF = 3.3
adc = machine.ADC(machine.Pin(28))
while True:
analog_value = adc.read_u16()
voltage = (analog_value / 65535) * V_REF
resistance = R1 / ((V_REF / voltage) - 1)
kelvin = 1 / (1 / 298.15 + 1 / BETA * math.log(resistance / 10000))
celsius = kelvin - 273.15
print("Temperature: {:.2f} ℃".format(celsius))
utime.sleep(1)
photoresistor_pin = 26
adc = ADC()
adc.width(ADC.WIDTH_10BIT)
def read_photoresistor_value():
return adc.read_u16()
while True:
value = read_photoresistor_value()
print("Photoresistor value:", value)
utime.sleep(1)