OLED with MicroPython on ESP32
Connection
- VCC to 3.3V
- GND to GND
- SCL/SCK to GPIO22
- SDA to GPIO21
Installations
- Need to install
SSD1306 OLED Library
- Open Editor ( Thonny or uPyCraft )
- Create a file named
ssd1306.py
- Copy the code from here
- Save the file
Code
from machine import Pin, SoftI2C
import ssd1306
from time import sleep
i2c = SoftI2C(scl=Pin(22), sda=Pin(21))
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
oled.text("Hello World", 0, 0)
oled.show()
- Filling or clearing the screen –>
oled.fill(0)
oled.show()
oled.pixel(0, 0, 1)
oled.show()
oled.invert(True)
oled.show()