OLED screen with RT1062

Im having a lot of trouble with driving a small OLED screen with my OpenMV cam, the RT1062. I found in the docs that there is a library for the SSD1306, but there aren’t any examples for it and the only information available is the library file itself. I’m not quite sure how the library itself works, so i asked an AI to make me an example, and I came to these issues:

  1. The library calls pybeven though it’s not used anywhere, but it causes problems with the RT1062 because it doesn’t support pyb but only machine
  2. Even after removing the pyb line, when i try to run the example it says that framebuf isn’t defined as well as self.poweron() in the initiation function for the library

This is my first time using MicroPython, so i don’t fully know how to use the libraries, should they be in the same folder as the code that I upload or be in the root of the OpenMV cam itself?

I wouldn’t mind using either I2C or SPI, but so far i’ve gotten errors with both and haven’t gotten anything to work.

Thanks in advance for any answers!

Hi, just use the display library and set the resolution for the module:

  1. Make sure you use the same pins on the RT1062 for the module: LCD Shield – OpenMV
  2. Use the display library like so:
import csi
import time
import display
import image

csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.QVGA)

# Initialize the lcd screen.
# Note: A DAC or a PWM backlight controller can be used to control the
# backlight intensity if supported:
#  lcd = display.SPIDisplay(backlight=display.DACBacklight(channel=2))
#  lcd.backlight(25) # 25% intensity
# Otherwise the default GPIO (on/off) controller is used.
#  OpenMV Cam M4/M7/H7/H7 Plus -> DAC and GPIO Support
#  OpenMV Cam RT1062 -> GPIO Support
#  OpenMV Cam N6 -> PWM and GPIO Support
lcd = display.SPIDisplay(width=320,
                         height=240,
                         bgr=True,
                         vflip=False,
                         hmirror=False)
clock = time.clock()

while True:
    clock.tick()
    lcd.write(csi0.snapshot(), hint=image.CENTER | image.SCALE_ASPECT_KEEP)
    print(clock.fps())

Regarding the exact piece of hardware you have, can’t exactly comment on it, but, what did you buy?

Hi, i have tried your little bit of code by replacing the display resolution as you said, but I cant get anything to show on it. I am unsure as to if I didnt plug the SPI communication right or if the display library simply isn’t made to drive small OLED displays. As to your question of what hardware i’m using, I have the 128x64 OLED display by Adafruit.

Mmm, maybe use this driver: GitHub - stlehmann/micropython-ssd1306: A fork of the driver for SSD1306 displays to make it installable via upip

I tried setting up I2C with the machine library, but the pin names i have using the reference sheet (P4 and P5) don’t work when I try calling them with the machine library. It says thet P4 and P5 arent defined, and if I try passing only 4 and 5, it says that the pins don’t exist, so what pin numbers should I use?

P4 and P5 are definitely defined for the RT1062.

However, setup the I2C like so:

from machine import I2C

i2c = I2C(1)  # The i2c bus must always be 1.
print(i2c.scan())  # Show attached devices.

Make sure to add pull ups on these pins (P4 and P5) if they aren’t on the OLED board already.