#08_i2c_OLED.py
from machine import Pin, SoftI2C
from time import sleep
import ssd1306
i2c = SoftI2C(scl=Pin(22), sda=Pin(21), freq=400000)
print("Scanning I2C (Low Speed)...")
devices = i2c.scan()
if devices:
for device in devices:
print(f"Decimal: {device} | Hex: {hex(device)}")
else:
print("No device found")
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
oled.fill(0)
'''
oled.text('Weatheer today', 8, 0, 1)
oled.text('Temp: 22.35 C', 0, 14, 1)
oled.text('Humi: 80.45 %', 0, 28, 1)
oled.text('Soil: 76.25 %', 0, 42, 1)
oled.text('LIght: 1234 Iux', 0, 54, 1)
'''
#1
#oled.hline(0, 8, 60, 1)
#oled.vline(0, 8, 40, 1)
#oled.line(0, 0, 127, 63, 1)
#oled.rect(10, 10, 107, 43, 1)
#oled.rect(20, 20, 87, 23, 1)
#2
oled.rect(0, 0, 127, 63, 1)
oled.rect(0, 0, 127, 15, 1)
oled.text('Weatheer today', 8, 3, 1)
oled.text('Temp: 22.35 C', 2, 17, 1)
oled.text('Humi: 80.45 %', 2, 29, 1)
oled.text('Soil: 76.25 %', 2, 41, 1)
oled.text('LIght: 1234 Iux', 2, 53, 1)
oled.show()Loading
esp32-devkit-c-v4
esp32-devkit-c-v4
Loading
ssd1306
ssd1306