I2c addresses

From BitWizard WIKI
Jump to: navigation, search

The I2C protocol is a bus protocol. Multiple devices can be connected. Usually several slaves and one master. To be able to use several slave devices each slave has an address. To be able to distinguish between read and write one bit is used, leaving 7 bits to separate slaves from each other.

There are two logical choices for the position of the read/write bit. You can put it at the left in the highest bit. This would mean you would use say 0x17 to read and 0x97 to write to a single device. This approach was not chosen. The read/write bit was chosen to be the lowest bit. 0x94 and 0x95 are write and read bytes to send for a single slave.

BitWizard has chosen to say that the slave has address 0x94 in this case. Just use that byte to address the device in write mode and add one to address it in read mode. We prefer to do it this way because there is now a clear and easy-to-do-in-your-head way go from an address to the byte-on-the-wire.

Other manufacturers and software-writers have chosen to display just the seven address bits. That means that the byte-on-the-wire is divided by two to get what they call "the address". For example a program like i2cdetect will display addresses this way. So the bitwizard address 0x94 will display as 0x4a in i2cdetect.

So when an rpi_ui starts up and displays "A: 94" it is exactly the same address as when i2cdetect shows a device at address 0x4a.