Raspberry Pi practice problem · I²C, SPI, UART & 1-Wire
Bus scanner
MediumBudget $18Python · gpiozero
i2cdetect finds devices by knocking on every address: a device that is there acknowledges, an empty address raises OSError (errno 121).
Build: two chips on the I²C pins, both on 3V3:
- an MPU-6050 with AD0 to GND (0x68),
- a BME280 with SDO to 3V3, which moves it to 0x77.
Program: try read_byte(address) for every address from 0x03 to 0x77, catching OSError. Print each address that answers, in order, then the total:
Found 0x68
Found 0x77
2 devices