ESP8266 – Oled I2C – Micropython

 

from machine import Pin, I2C
import ssd1306
from time import sleep

# 1 3 Busy

GREEN = Pin(0, Pin.OUT)    
GREEN.on()

BLUE_OLED = Pin(2, Pin.OUT)   
BLUE_OLED.on()

def do_connect():
    import network
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    if not wlan.isconnected():
        print('connecting to network...')
        wlan.connect('ssd', 'pass')
        while not wlan.isconnected():
            pass
    print('network config:', wlan.ifconfig())
    
do_connect()

i2c = I2C(-1, scl=Pin(4), sda=Pin(5))

print(i2c.scan())

oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)

oled.text('Hello, World 1!', 0, 0)
oled.text('Hello, World 2!', 0, 10)
oled.text('Hello, World 3!', 0, 20)
        
oled.show()