from machine import ADC
from time import sleep
import math
thermistor = ADC(28)
Ro = 10000 # 10k Resistor
A = 0.001129148;B = 0.000234125;C = 0.0000000876741
def read_temperature():
# Get Voltage value from ADC
adc = thermistor.read_u16()
Vout = (3.3/65535) * adc
Rt = (Vout * Ro) / (3.3 - Vout)
TempK = 1 / (A + (B * math.log(Rt)) + C * math.pow(math.log(Rt), 3))
TempC = TempK - 273.15
return round(TempC, 1)
while True:
temperature = read_temperature()
print(temperature)
sleep(0.5)