🛠 OLED Qwiic sur le bus I2C 5 (mcu_i2c0)
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
- A BeaglePlay board
- A Qwiic SSD1306 OLED display, 0.91" or 0.96" (address 0x3C)
- A 4-wire Qwiic cable (or jumper wires to the connector: 3V3, GND, SDA, SCL)
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
- Scanning the wrong bus: the Qwiic connector is indeed bus 5 (
mcu_i2c0), not the Grove bus;i2cdetect -lconfirms the controller label. - Powering the OLED from an unpowered pin: the bus remains correct but the screen does not initialize.
- Forgetting the write prefix 0x00 (command) / 0x40 (data): the initialization goes unnoticed.
- Two Qwiic devices at address 0x3C: the second one does not appear in
i2cdetect; you need an addressable screen (0x3D). - Running everything as root: add the user to the
i2cgroup to runi2cdetectwithout sudo.
Other tutorials for this board
- Flasher l'image Debian sur la microSD puis l'eMMC 16 Go
- LED et bouton USER : triggers kernel et gpio-keys
- Capteurs Grove sur le bus I2C 1 et inventaire du bus
- Double Ethernet : GbE RTL8211F et 10BASE-T1L sur RJ11
- Caméra CSI OV5640 via fdtoverlays dans extlinux.conf
- Reflasher le CC1352P7 en BSL depuis le processeur hôte
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash