from machine import Pin, SoftI2C, ADC
from math import log
from i2c_lcd import I2cLcd
from time import sleep
myADCinput = ADC(Pin(2)) #pin 2 will be used as an ADC input line
lcd_address = 0x26
i2c = SoftI2C(scl = Pin(22), sda = Pin(23), freq = 400000)
lcd = I2cLcd(i2c, lcd_address, 2, 16) # the display has 2 rows and 16 columns
beta = 3950 # beta coefficient of the thermistor being used
kelvin = 273.15 # value of temperature in Kelvin at zero Celsius
while True:
ADC_value = myADCinput.read()
lcd.move_to(0,0)
temperature_in_celsius = 1 / (log(1 / (4096 / ADC_value - 1))/beta + 1.0 / 298.15) - kelvin
temperature_in_celsius=round(temperature_in_celsius,1)
lcd.putstr('Temp is: ') # print to LCD display
lcd.putstr(str(temperature_in_celsius)) # print to LCD display
lcd.putstr(' ') # print to LCD display
sleep(.2)