Hardware Reference
In-Depth Information
Wiring and Testing
The connections to the MCP23017 are simple enough that you can wire it up on a
breadboard. The first step after wiring is to determine that you can detect the peripheral
on the I2C bus.
But even before that, check your kernel module support. If lsmod doesn't show these
modules loaded, you can manually load them now:
$ sudo modprobe i2c−dev
$ sudo modprobe i2c−bcm2708
If you haven't already done so, install i2c-tools :
$ sudo apt−get install i2c−tools
If your I2C support is there, you should be able to list the available I2C buses:
$ i2cdetect −l
i2c −0 unknown bcm2708_i2c.0 N/A
i2c −1 unknown bcm2708_i2c.1 N/A
The I2C device nodes should also appear in /dev . These nodes give us access to the
I2C drivers:
$ ls −l /dev/i2c
crw−rw−−−T 1 root root 89, 0 Feb 18 23:53 /dev/i2c−0
crw−rw−−−T 1 root root 89, 1 Feb 18 23:53 /dev/i2c−1
The ultimate test is to see whether the MCP23017 chip is detected (change the 1 to 0
for older Pi revisions):
$ sudo i2cdetect −y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: −− −− −− −− −− −− −− −− −− −− −− −− −−
10: −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −−
20: 20 −− −− −− −− −− −− −− −− −− −− −− −− −− −− −−
30: −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −−
40: −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −−
50: −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −−
60: −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −−
70: −− −− −− −− −− −− −− −−
In this example, the A2, A1, and A0 pins of the MCP23017 were grounded. This gives
the peripheral the I2C address of 0x20 . In the session output, we see that address 0x20
was detected successfully.
 
Search WWH ::




Custom Search