PyRaspBeta

← All practice problems

Raspberry Pi practice problem · I²C, SPI, UART & 1-Wire

Who is on the bus?

EasyBudget $10Python · gpiozero

Every I²C chip answers at an address, and most keep a fixed ID register you can read to make sure the right chip is there.

Build: a BME280 on the I²C pins (GPIO2 SDA, GPIO3 SCL), powered from 3V3, with its SDO pin to GND so it answers at 0x76.

Program: with smbus2, read one byte from register 0xD0 of address 0x76 and print it in hex:

Chip ID: 0x60

Tip: SMBus(1).read_byte_data(0x76, 0xD0), then f"0x{value:02x}". A BME280 always answers 0x60.

More in I²C, SPI, UART & 1-Wire