🛠 Capteurs Grove sur le bus I2C 1 et inventaire du bus

BeaglePlay (TI Sitara AM6254 / AM625) · intermediaire · Schéma : IMG-beagleplay-intermediaire-1-grove-i2cdetect-i2c1.svg — Un capteur Grove I2C branché sur le connecteur Grove du bus I2C 1 du BeaglePlay, avec la grille i2cdetect affichant les adresses détectées

Objectives

Use the BeaglePlay Grove connectors on the I2C side: the Grove connector is connected to I2C bus 1. We enable the bus, list the occupied addresses with i2cdetect, then read a Grove sensor (for example BME680 at 0x77 or BME280 at 0x76) using raw register reads, without relying on a manufacturer library.

Hardware

Complete code

# Vérifier que le bus 1 (Grove) est actif
i2cdetect -l
sudo i2cdetect -y -r 1        # grille des adresses 0x08-0x77

# Lecture brute d'un registre (exemple : ID BME680 attendue 0x61)
sudo i2cget -f -y 1 0x77 0xD0

# Script d'inventaire automatique
for a in $(seq 8 119); do
  if sudo i2cget -f -y 1 $a 0x00 >/dev/null 2>&1; then
    printf "présent : 0x%02x\n" $a
  fi
done
# lecture SMBus simple (pip install smbus2)
import smbus2
bus = smbus2.SMBus(1)
print(hex(bus.read_byte_data(0x77, 0xD0)))

Expected verification

i2cdetect -l lists at least bus 1 (Grove) and bus 5 (Qwiic). With a sensor connected, i2cdetect -y -r 1 displays its address (e.g., 77); the inventory script retrieves it. i2cget on the identification register returns the value expected by the datasheet (0x61 for BME680, 0x60 for BME280).

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials