import time
from machine import ADC, I2C, SoftI2C, Pin, Timer, RTC
from pico_i2c_lcd import I2cLcd
import math
i2c = SoftI2C(sda=Pin(20),scl=Pin(19),freq=400000)
addr = i2c.scan()[0]
print(hex(addr))
lcd = I2cLcd(i2c, addr, 16, 2)
lcd.clear()
rtc = RTC()
button = Pin(12,Pin.IN)
sensor = ADC(26)
check = True
def display(button):
global check
if check:
lcd.clear()
check = False
return
check = True
BETA = 3950; # should match the Beta Coefficient of the thermistor
analogValue = sensor.read_u16()
celsius = 1 / (math.log(1 / (65535. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15
lcd.putstr(f"{celsius}")
time.sleep(1)
print(celsius)
print(sensor.read_u16())
button.irq(display, trigger=button.IRQ_FALLING)