from lcdi2c import*
from utime import sleep
from machine import Pin,ADC
from math import log
BETA = 3950
sensor=ADC(Pin(27))
cmd_wrt(0xc0+0)
string_write("LAB 6")
cmd_wrt(0xc0+8)
string_write("EMBEDDED")
def display(temp):
cmd_wrt(0x80)
string_write("temp:")
string_write(str(int(temp)))
string_write("^C")
def get_temp():
nilai=sensor.read_u16() #get reading in digital
voltage=nilai/65535*3.300 #get reading in voltage
print(nilai,voltage)
celsius = 1 / (log(1 / (65535.00 / nilai - 1)) / BETA + 1.0 / 298.15) - 273.15;
print("temperature",celsius,"^C")
return celsius
lcd_start()
while 1:
display(get_temp())
sleep(0.2)