import machine
import time
import ssd1306
i2c = machine.I2C( 0, sda=machine.Pin(4), scl=machine.Pin(5), freq=400000)
oled = ssd1306.SSD1306_I2C( 128 , 64 , i2c)
sensor_temp = machine.ADC(4)
conversion_factor =3.3/65535
print("Experiment 3.2: I2C OLED Display Starting...")
while True:
reading = sensor_temp.read_u16()*conversion_factor
temperature = 27 - (reading - 0.706)/0.001721
oled.fill(0)
oled.text("IOT MONITOR",20,0)
oled.hline(0,10,128,1)
oled.text("Status: ONLINE", 0,20)
olded.text(f"Temp: {temperature:.1f} C",0,40)
oled.show()
time.sleep(1)