Hardware Reference
In-Depth Information
This is our first I2C bus; it's also the one connected to the GPIO pins. Another way to find your I2C bus is to scan
for all I2C buses on the system; you do this via the i2cdetect command. Run the following to list all available I2C
buses on your system:
# i2cdetect -l
I prefer to list the dev tree nodes but both tools will give you a similar output. Now that you have the bus ID let's
scan the bus before we turn on the LCD. The syntax for i2cdetect will be quite simple if you just wish to scan the bus.
Depending on the model of the Raspberry Pi you have you may need to use /dev/i2c-0 or /dev/i2c-1 ; it's safe to
scan both buses. Run the following command to scan the /dev/i2c-0 bus:
# i2cdetect 0
Answer yes when prompted to scan the address range. If you don't see your device, try to scan the next bus until
you see your device. In Figure 4-16 you can see the scan has run and no devices are detected.
Figure 4-16. Nothing found on the I2C bus
Now turn on the LCD and the shift register. Let's run the exact same scan again. How exciting that something was
found! If you take a look at Figure 4-17 you can see at address 0x38 that the scan found a device.
Figure 4-17. An I2C slave found at 0¥38
 
Search WWH ::




Custom Search