OLED Unit
Unit OLED is a 1.3-inch OLED expansion screen unit. Driveing by SH1107, and the resolution is 128*64, monochrome display.
Support the following products:
UiFlow2 Example
Draw Text
Open the cores3_oled_example.m5f2 project in UiFlow2.
This example displays the text “OLED” on the screen.
UiFlow2 Code Block:
Example output:
None
MicroPython Example
Draw Text
This example displays the text “OLED” on the screen.
MicroPython Code Block:
1# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from hardware import I2C 9from hardware import Pin 10from unit import OLEDUnit 11 12 13label0 = None 14label1 = None 15i2c0 = None 16oled_0 = None 17 18 19def setup(): 20 global label0, label1, i2c0, oled_0 21 22 M5.begin() 23 Widgets.fillScreen(0x222222) 24 label0 = Widgets.Label("CoreS3", 127, 109, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 25 26 i2c0 = I2C(0, scl=Pin(1), sda=Pin(2), freq=100000) 27 oled_0 = OLEDUnit(i2c0, 0x3C) 28 label1 = Widgets.Label("OLED", 5, 53, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18, oled_0) 29 30 31def loop(): 32 global label0, label1, i2c0, oled_0 33 M5.update() 34 35 36if __name__ == "__main__": 37 try: 38 setup() 39 while True: 40 loop() 41 except (Exception, KeyboardInterrupt) as e: 42 try: 43 from utility import print_error_msg 44 45 print_error_msg(e) 46 except ImportError: 47 print("please update to latest firmware")
Example output:
None
API
class OLEDUnit
- class unit.oled.OLEDUnit(i2c, address=60)
Bases:
objectInitialize the OLED Unit.
- Parameters:
i2c (I2C | PAHUBUnit) – The I2C bus the OLED Unit is connected to.
address (int) – The I2C address of the OLED Unit, default is 0x3C.
UiFlow2 Code Block:

MicroPython Code Block:
from unit import OLEDUnit oled_0 = OLEDUnit(i2c0, 0x3c)
OLEDUnit class inherits Display class, See hardware.Display for more details.

