Question 8.5: You have an I2C device attached to your Raspberry Pi, and yo......

You have an I2C device attached to your Raspberry Pi, and you want to know how to check that it’s attached and to find its I2C address.

Step-by-Step
The 'Blue Check Mark' means that this solution was answered by an expert.
Learn more on how do we answer questions.

Install and use i2c-tools.

On newer distributions, you may find that i2c-tools is already installed.

From a Terminal window on your Pi, type the following commands to fetch and install the i2c-tools:

$ sudo apt-get install i2c-tools

Attach your I2C device to the Pi and run the command:

$ sudo i2cdetect -y 1

Note that if you are using an older revision 1 board, you need to change 1 to 0 in the preceding code line.

If I2C is available, you will see some output like that shown in Figure 8-3. This shows that two I2C addresses are in use—0x40 and 0x70.

Discussion

i2cDetect is a useful diagnostic tool and one that is worth running the first time you use a new I2C device.

See Also

See some of the I2C recipes in this book: Recipes 10.2, 13.1, 13.2, and 13.4.

For more information on installing with apt-get, see Recipe 3.16.

8.3

Related Answered Questions

Question: 8.16

Verified Answer:

The PiFace Digital (“Modules” on page 381) is an e...
Question: 8.15

Verified Answer:

Use a boost regulator module (Figure 8-10). The mo...
Question: 8.14

Verified Answer:

A typical project using a Raspberry Pi requires 5V...
Question: 8.11

Verified Answer:

Use a Pi Cobbler, a device consisting of a small p...
Question: 8.9

Verified Answer:

Install Minicom: $ sudo apt-get install minicom...
Question: 8.21

Verified Answer:

You can use the paddle terminal breakout board sho...
Question: 8.20

Verified Answer:

The Pi Plate (Figure 8-16) is a prototyping board ...
Question: 8.19

Verified Answer:

The Humble Pi (Figure 8-15) is a prototyping board...
Question: 8.17

Verified Answer:

Figure 8-13 shows a Gertboard attached to a Raspbe...