import machine
import utime
import math
# Configurações do ADC e termistor
adc = machine.ADC(26) # Pino GP26 (ADC0)
BETA = 3950 # Coeficiente Beta do termistor
def read_temperature():
# Leitura do ADC (conversão para 10 bits)
adc_value = adc.read_u16() * 1023 / 65535
# Cálculo da temperatura usando a equação Beta
return 1 / (math.log(1 / (1023.0 / adc_value - 1)) / BETA + 1.0 / 298.15) - 273.15
while True:
temperature = read_temperature()
print(f"Temperature: {temperature:.2f} ℃")
utime.sleep(1)