Qwiic SHIM for Raspberry Pi Hookup Guide

Pages
Contributors: El Duderino, Ell C
Favorited Favorite 4

Scanning for I2C Devices

If you are using the Raspberry Pi to quickly connect to I2C devices, the best place to start would be to scan for an I2C device on the bus.

Utilities

There is a set of command-line utility programs that can help get an I2C interface working. You can get them with the apt package manager.

language:bash
sudo apt-get install -y i2c-tools

In particular, the i2cdetect program will probe all the addresses on a bus, and report whether any devices are present. Enter the following command in the command line. The -y flag will disable interactive mode so that you do not have to wait for confirmation. The 1 indicates that we are scanning for I2C devices on I2C bus 1 (e.g. i2c-1).

language:bash
i2cdetect -y 1

You will get an output from your Raspberry Pi similar to the output below.

language:bash
pi@raspberrypi:~/$ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

This map indicates that there is a peripheral at address 0x60. Your address may vary depending on what is connected to the I2C bus. For advanced users, you can try to read and write its registers using the i2cget, i2cset and i2cdump commands.

Qwiic Py Drivers

Now that you have I2C set up on your Pi, you can start programming your Qwiic devices on your Pi or if you'd like to start with some examples, we have a host of Python drivers for Qwiic breakouts available in the GitHub repository linked below. You can read more about Python for the SparkFun Qwiic system in this blog post.