Utilities
There is a set of command-line utility programs that can help get an I2C interface working. You can
get them with the apt package manager.
COPY CODEsudo apt-get install -y i2c-tools
In particular, the
i2cdetect
program will probe all the addresses on a bus, and report whether any
devices are present. Call
i2cdetect -y 1
to probe the first I
2
C bus, which is what the Qwiic HAT is
connected to.
COPY CODEpi@raspberrypi:~/$ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
This map indicates that there is a peripheral at address 0x60. We can read and write its registers
using the
i2cget
,
i2cset
and
i2cdump
commands.