Last active
February 8, 2022 03:22
-
-
Save laurivosandi/1dcc68aa1e665336f4867a4d81ce64b7 to your computer and use it in GitHub Desktop.
OLED screen demo on ESP32 with MicroPython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pull the SDD1306 lib from here https://github.com/adafruit/micropython-adafruit-ssd1306/blob/master/ssd1306.py | |
from time import sleep_ms | |
from machine import Pin, I2C | |
from ssd1306 import SSD1306_I2C | |
buf = "wubba lubba dub dub " | |
i2c = I2C(-1, Pin(4),Pin(5),freq=40000) # Bitbanged I2C bus | |
assert 60 in i2c.scan(), "No OLED display detected!" | |
oled = SSD1306_I2C(128, 64, i2c) | |
oled.invert(0) # White text on black background | |
oled.contrast(255) # Maximum contrast | |
for j in range(0, 500): | |
oled.fill(0) | |
oled.text(buf[j%len(buf):]+buf, 10, 10) | |
oled.show() | |
sleep_ms(40) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing this. It helped me to sort out the issue with "ESP32 OLED V2.0 TTGO" board I've got from AliExpress (it comes with a screen soldered). It uses pins 4 and 15 (not 5), and the screen's reset pin is 16 (I don't know why they chose such wiring).
My code: