🛠 OLED Qwiic sur le bus I2C 5 (mcu_i2c0)

BeaglePlay (TI Sitara AM6254 / AM625) · debutant · Schéma : IMG-beagleplay-debutant-3-oled-qwiic-i2c5.svg — Un écran OLED I2C adresse 0x3C relié par câble Qwiic au connecteur du bus I2C 5 (mcu_i2c0) du BeaglePlay, avec le lien /dev/play/qwiic

Objectives

Set up an I2C OLED display (SSD1306 controller, address 0x3C) on the BeaglePlay Qwiic connector. The Qwiic connector is wired to the mcu_i2c0 controller, exposed on the Linux side as I2C bus number 5. You will learn how to scan the bus with i2cdetect, and then write to it from Python using smbus2.

Hardware

Complete code

# Le bus Qwiic est le bus 5 (mcu_i2c0) ; le lien symbolique est fourni
ls -l /dev/play/qwiic
sudo i2cdetect -y -r 5     # la case 3c doit apparaître
# pip install smbus2
import smbus2
bus = smbus2.SMBus(5)

def cmd(c):
    bus.write_byte_data(0x3C, 0x00, c)

for c in [0xAE,0xD5,0x80,0xA8,0x3F,0xD3,0x00,0x40,0x8D,0x14,
          0xA1,0xC8,0xDA,0x12,0x81,0xFF,0xD9,0xF1,0xDB,0x40,
          0xA4,0xA6,0xAF]:
    cmd(c)

bus.write_i2c_block_data(0x3C, 0x40, [0xFF]*128)  # ligne allumée

Expected verification

sudo i2cdetect -y -r 5 displays 3c in the grid (the -- on the 0x00 line is normal). After sending the initialization sequence, the OLED displays a full white bar. If the screen is not visible, first check the 3V3 supply and the SDA/SCL wiring.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials