🛠 Interroger un capteur I2C sur le connecteur 40 broches
Objectives
Connect an I2C sensor or peripheral (OLED SSD1306, BME280, CO2 sensor…) to the 40-pin connector of the ROCK 3B and detect it with i2c-tools. The official documentation lists 3 I2C controllers on the connector (header function table); the exact pins depend on the muxing of your hardware revision — the number of functions varies between the CNX launch sheet and the current documentation, so we verify on the board.
Hardware
- Radxa ROCK 3B running Radxa OS (or mainline ≥ 6.11 with overlays enabled)
- 3.3 V I2C sensor (SSD1306 at 0x3c, BME280 at 0x76/0x77)
- 4 Dupont wires: 3.3 V, GND, SDA, SCL (identified by the connector's color code, official plan at docs.radxa.com)
Complete code
sudo apt install i2c-tools
# Activer le contrôleur I2C du connecteur (Radxa OS : outil rsetup)
sudo rsetup # Interface/Overlay settings -> activer l'I2C du header, reboot
sudo modprobe i2c-dev
i2cdetect -l # lister les contrôleurs i2c-0, i2c-1...
# Identifier le bus du connecteur via le device tree :
for d in /sys/bus/i2c/devices/i2c-*; do
echo "$d : $(cat $d/of_node/fullname 2>/dev/null)"; done
sudo i2cdetect -y N # N = bus du connecteur repéré ci-dessus
sudo i2cget -y N 0x76 0xd0 # exemple : ID du BME280 -> 0x60
Expected verification
i2cdetect -y N displays a grid where the sensor's address appears (3c, 76, 77…); i2cget returns a consistent value (0x60 for the BME280). No UU if no kernel driver already claims the module.
Common errors
- Scanning the wrong bus: the RK809 PMIC (audio/power) sits on an internal bus, not on the connector — use
of_node/fullnameto find the bus wired to the header. - I2C disabled by default: without an enabled overlay (rsetup under Radxa OS,
&i2c2 status="okay"in mainline),i2cdetect -lshows nothing matching the connector. - Relying on a pinout inherited from the ROCK Pi 4 or an old wiki: Radxa's documentation itself has evolved between revisions (Revision Details page) — check the V1.51 schematic of your board.
- Powering a 5 V module whose logic pins are not 5V-tolerant: stay at 3.3 V on this board.
- Two modules at the same address: plan for a TCA9548A multiplexer or shift the address (ADR).
Other tutorials for this board
- Faire clignoter une LED via le GPIO avec libgpiod
- Lire un bouton poussoir en Python avec python3-libgpiod
- Premier réseau : Ethernet double gigabit, Wi-Fi optionnel et SSH
- Installer et booter le système sur un SSD NVMe (M.2 M-Key)
- Surveiller température et fréquence CPU, piloter le ventilateur PWM
- Routeur / passerelle réseau double Gigabit avec OpenWrt et PoE
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash