🛠 Capteur BME280 (I2C) sur Le Potato : overlay et lecture
Objectives
Enable the I2C interface on the Le Potato's 40-pin header (disabled by default) and read a BME280 sensor (temperature, humidity, pressure) in Python.
Hardware
- Le Potato AML-S905X-CC running Armbian mainline
- BME280 module (default address 0x76, 0x77 if ADDR=1)
- Wiring 3.3 V / GND / SDA / SCL to the I2C pins on the header (no 5 V pin)
sudo apt install i2c-tools python3-smbus
Complete Code
# 1) Activer l'I2C : sudo armbian-config -> System > Options > HW interfaces
# (ou overlay dédié, cf. « How to Enable I2C on AML-S905X-CC » sur hub.libre.computer)
sudo reboot
sudo i2cdetect -y 0 # le bus peut être i2c-0 ou i2c-1 : ls /dev/i2c-*
#!/usr/bin/env python3
# bme280.py — lecture brute des registres (bus 0, adresse 0x76)
import smbus, time
bus = smbus.SMBus(0); ADDR = 0x76
bus.write_byte_data(ADDR, 0xD0, 0x00) # soft reset
reg = bus.read_byte_data(ADDR, 0xD0)
print("chip id:", hex(reg)) # attendu 0x60
bus.write_byte_data(ADDR, 0xF4, 0x27) # t+p oversampling x1
bus.write_byte_data(ADDR, 0xF5, 0x00) # mode forcé
def lire(reg): # 24 bits signé, format BME280
v = (bus.read_byte_data(ADDR, reg) << 12) | \
(bus.read_byte_data(ADDR, reg+1) << 4) | \
(bus.read_byte_data(ADDR, reg+2) >> 4)
return v - 16777216 if v > 8388607 else v
time.sleep(0.1)
print("temp brute:", lire(0xFA) / 100.0, "degres")
Expected Verification
i2cdetect -y 0 displays 0x76; the script prints chip id: 0x60 and a consistent temperature (the raw calibrated field is sufficient for a test; for accuracy, use the bme280/adafruit-circuitpython-bme280 library with the bus explicitly passed).
Common Errors
- I2C overlay not enabled: "Could not open device" — I2C is NOT active by default on this board.
- Wrong bus number: try
i2cdetect -y 1; CircuitPython requires the explicit bus. - 5 V bus or 5 V module pulled to 5 V: the pins only accept 3.3 V.
chip id: 0x00: SDA/SCL wiring reversed or address 0x77.
Other tutorials for this board
- Faire clignoter une LED en C avec libgpiod sur Le Potato
- Lire un bouton poussoir avec libgpiod (pull-up interne)
- GPIO en Python avec python3-libgpiod sur Le Potato
- Fondu LED progressif avec PWM sous sysfs (meson)
- Console série (ttyAML0) et SSH sur Le Potato
- Boot SD/eMMC et récupération (pyamlboot) sur Amlogic S905X
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash