🛠 Faire clignoter une LED sur les GPIO du CM3
Objectives
Learn how to control a GPIO output on the CM3 using the gpiozero library (provided with Raspberry Pi OS). The CM3 exposes 48 GPIO lines (GPIO0-45) on the SODIMM connector, divided into two independent power banks: bank0 (GPIO0-27) and bank1 (GPIO28-45). Each bank operates at the voltage of its VREF pin, ranging from 1.8 V to 3.3 V — on the CMIO3, the connector is at 3.3 V.
Hardware
- CM3 (or CM3 Lite) on CMIO3, with Raspberry Pi OS started (see "assembler-kit-cm3-cmio3")
- 1 LED + 330 Ω resistor between GPIO17 and GND
- No level shifter needed at 3.3 V; however, on a custom carrier board with a bank at 1.8 V, a standard LED may not light up — check the VREF rail of the relevant bank
Complete Code
#!/usr/bin/env python3
# blink.py — LED sur GPIO17 (bank0), numérotation BCM identique au Pi 3
from gpiozero import LED
from time import sleep
led = LED(17) # GPIO17, bank0 ; la tension de sortie = tension VREF de la banque
while True:
led.on
sleep(1)
led.off
sleep(1)
sudo apt update && sudo apt install python3-gpiozero
python3 blink.py
Expected Verification
The LED blinks at 1 Hz (1 s on, 1 s off). Ctrl-C stops the program. The command gpioread 17 (wiringPi) or gpiodetect / gpioinfo gpiochip0 (libgpiod) confirms that the pin is correctly configured as an output.
Common Errors
- Confusing SODIMM GPIOs with the 40-pin connector pins of a classic Pi 3: here, the BCM numbering corresponds directly to the GPIO numbers on the SODIMM connector.
- Touching GPIO28, 29, 44, or 45 without external pull resistors: these pins do NOT have default pull resistors (RP-008161-DS datasheet §9.1) and float at startup; add off-chip pulls on a custom board.
- Reusing HDMI_HPD_N_1V8 or EMMC_EN_N_1V8 as GPIOs: these pins are reserved for the firmware; repurposing them breaks boot or HDMI functionality.
- Exceeding 16 mA per pin and 50 mA per bank: an LED without a resistor can destroy the output.
Other tutorials for this board
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash