from machine import Pin, I2C, ADC from ssd1306 import SSD1306_I2C import machine import utime
led = Pin(5, Pin.OUT)
sensor_temp = machine.ADC(4) conversion_factor = 3.3 / (65535)
WIDTH = 128HEIGHT = 64
i2c = I2C(0, scl=Pin(9), sda=Pin(8), freq=200000)print("I2C Address : "+hex(i2c.scan()[0]).upper()) print("I2C Configuration: "+str(i2c))
oled = SSD1306_I2C(WIDTH, HEIGHT, i2c)
while True: reading = sensor_temp.read_u16() * conversion_factor temperature = 60- (reading - 0.0)/0.001721 fahrenheit = temperature * 9 / 5 + 32 print("Temperatura:",temperature,"°C") print("Temperatura:",fahrenheit,"°F")
oled.fill(0)
oled.text("Temp. da Maquina:",0,0)
oled.text("Temp: ",6,10)
oled.text(str(round(temperature,2)),50,10)
oled.text("C",95,10)
utime.sleep(2)
if temperature >= 60:
oled.text("Perigo!",40,20)
oled.text("Temp. Alta!",20,30)
led.toggle()
oled.show()