The Sensor

A notable characteristic of a silicon diode is its temperature sensitivity: its forward voltage decreases by roughly 2 mV for each degree Celsius rise, maintaining a fairly linear behavior between 0 and 100 °C. Because the base-emitter junction of a transistor behaves just like a diode, individual transistors can be conveniently used as simple and reliable temperature sensors.

Okay, let's write a Python script that reads our values from the ADC first. As our XAIO board has SAMD21G18 MCUI, it has a nice 1.0V reference source inside, and we will use it, as it has  1% tolerance, and we may measure precisely 

from machine import Pin, Timer, ADC

# -----------------------------
# Setup LED on pin 18
# -----------------------------
led = Pin(18, Pin.OUT)  # digital output for blinking
counter = 0             # simple counter for LED toggle

# -----------------------------
# ADC setup
# -----------------------------
ADC_CONVERT_V = 1.0 / 65535.0  # conversion factor: raw ADC (16-bit) → voltage (vref=1.0V)

adc = ADC(4, vref=0)  # ADC on pin A4, using internal 1.0V reference
adcVoltage = 0.0       # variable to store measured voltage

# -----------------------------
# Timer callback function
# -----------------------------
def fun(tim):
    global counter, adcVoltage  # make sure we update the global variables
    counter += 1                # increment counter
    adcVoltage = adc.read_u16() * ADC_CONVERT_V  # read ADC and convert to voltage
    print(adcVoltage)           # print voltage to REPL
    led.value(counter % 2)      # toggle LED every callback (blink)

# -----------------------------
# Initialize periodic timer
# -----------------------------
tim = Timer(-1)                    # create a virtual timer
tim.init(period=1000,               # callback period in milliseconds (1000 ms = 1 s)
         mode=Timer.PERIODIC,      # periodic callback
         callback=fun)              # function to call

 We see nice outputs on the shell:

0.5708095
0.5708095
0.57056532
0.57056532
0.5708095
0.5708095
0.57056532 

Nice. Now we need to add a 1-wire thermosensor to calibrate our own (made from transistor)