from machine import Pin, ADC
from time import sleep
from math import log
def Temp(termistor):
resistencia = 10000.0 * (termistor / (4095.0 - termistor))
tempK = log(resistencia)
tempK = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * tempK * tempK)) * tempK)
tempC = tempK - 273.15
return tempC
adc = ADC(Pin(34))
adc.atten(ADC.ATTN_11DB)
print("\n#### Iniciando Programa ####\n")
while True:
valor = adc.read()
temp = Temp(valor)
print("Sensor: ", valor)
print("Temperatura: ", round(temp,1), "°C")
sleep(1.0)