Hardware Reference
In-Depth Information
Addressing I2C Devices
So how will the I2C bus know which device to communicate with? Each slave device will have either a seven-bit or
ten-bit address. This address should be unique on the given I2C bus. On most slave devices you can set the address
or at least some bits of the address. The Raspberry Pi can address either seven-bit or ten-bit devices. Given this
large address space, that's a lot of I2C devices you can support on just two wires! The ten-bit addressing method is
backward-compatible with the seven-bit addressing method. So you can mix ten-bit and seven-bit devices on the
same single bus. In Figure 4-8 you can see what a typical seven-bit address will look like on the bus.
Read/
Write
Slave Adress
Start
Condition
A6
A5
A4
A3
A2
A1
A0
R/W
S
Most significant bit to least significant bit
Figure 4-8. An example of a seven-bit I2C address
The I2C bus has a few distinct advantages that make it a good candidate for your projects. First, as you now know,
it's a two-wire bus, and you will be saving the precious GPIO pins on the Raspberry Pi. Second, as the name implies,
I2C is a bus topology. Let's talk more about this bus.
The Bus Itself
The I2C bus is a multimaster bus, meaning you can have more than one master device on the bus and many slave
devices. The master in our case is the Raspberry Pi. In addition to this the master and slave roles can be reversed if
requested by the slave and master. In Figure 4-9 you can see an I2C bus with two slave devices. For our use you will
have only one master.
Vdd
Pull up resistors
SDA
SCL
Raspberry
Pi
Shift
Register
RTC
Master
Slave
Slave
Figure 4-9. An I2C bus with two slaves and one master
 
Search WWH ::




Custom Search