import time
import math
from machine import ADC
from machine import Pin, I2C
import ssd1306
pin = Pin(32, Pin.IN)
adc = ADC(pin)
adc.width(ADC.WIDTH_12BIT)
adc.atten(ADC.ATTN_11DB)
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
while True:
temperature = 1 / (math.log(1 / (4096 / adc.read() - 1)) / 3950 + 1.0 / 298.15) - 273.15;
text = str(temperature)
oled.fill(0)
oled.text(text, 30, 25)
oled.show()
time.sleep_ms(1000)