Build a digital thermometer using a thermistor — a resistor whose resistance changes with temperature — converting its ADC reading into a real temperature in °C.
A thermistor is a temperature-sensitive resistor: its resistance changes as temperature changes, wired into a voltage divider exactly like the photoresistor in Night Lamp.

The relationship between a thermistor’s resistance and temperature is:
Rt = R * EXP[ B * (1/T2 - 1/T1) ]
Rt: thermistor resistance at temperature T2R: nominal resistance at reference temperature T1B: the thermistor’s thermal index (a constant specific to the part)T1, T2: absolute (Kelvin) temperatures — Kelvin = 273.15 + CelsiusFor this thermistor: B = 3950, R = 10kΩ, T1 = 25°C.
Solving that formula for temperature instead of resistance gives:
T2 = 1 / ( 1/T1 + ln(Rt/R)/B )
So the process is: read the ADC → calculate voltage → calculate Rt from the voltage divider → calculate temperature from Rt.


Connections:

Disconnect all power before building the circuit. Reconnect once verified.
File: 03_sensors/code/Thermometer.py
from machine import Pin,ADC
import time
import math
adc=ADC(Pin(1))
adc.atten(ADC.ATTN_11DB)
adc.width(ADC.WIDTH_12BIT)
try:
while True:
adcValue=adc.read()
voltage=adcValue/4095*3.3
Rt=10*voltage/(3.3-voltage)
tempK=(1/(1/(273.15+25)+(math.log(Rt/10))/3950))
tempC=tempK-273.15
print("ADC value:",adcValue,"\tVoltage :",voltage,"\tTemperature :",tempC);
time.sleep_ms(1000)
except:
pass
03_sensors/code/.Thermometer.py.adcValue=adc.read()
voltage=adcValue/4095*3.3
Converts the raw 0–4095 ADC reading into a 0–3.3V voltage.
Rt=10*voltage/(3.3-voltage)
Since the thermistor (Rt) and the fixed 10kΩ resistor form a voltage divider across 3.3V, the voltage at their junction lets us solve for Rt algebraically.
tempK=(1/(1/(273.15+25)+(math.log(Rt/10))/3950))
tempC=tempK-273.15
Applies the rearranged thermistor formula (B=3950, R=10kΩ, T1=25°C) to get the temperature in Kelvin, then converts to Celsius.
math.log(): natural logarithm, used here to invert the exponential thermistor formulaSee Class ADC for the full API reference.
tempF = tempC * 9/5 + 32.Adapted from Python_Tutorial.pdf Project 12.1