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.01727
oled.fill(0)
oled.text("IOT MONITOR",20,0)
oled.hline(0,10,128,1)
oled.text("STATUS: ONLINE",0,20)
oled.text(f"Temp: {temperature:.1f} C",0,40)
oled.show()
time.sleep(1)