Qwiic SHIM for Raspberry Pi Hookup Guide
2020-02-20 | By SparkFun Electronics
License: See Original Project Raspberry Pi
Courtesy of SparkFun
Introduction
The SparkFun Qwiic SHIM for Raspberry Pi is a small, easily removable breakout to add a Qwiic connector to your Raspberry Pi. The SHIM (short for Shove Hardware in the Middle) design allows you to plug directly to the Pi's I2C bus with no soldering required and the thin PCB design allows for it to be sandwiched on your Pi GPIO with other HATS. The Qwiic SHIM works great when you do not need the full capabilities of the Qwiic pHAT for Raspberry Pi or if you want to add a Qwiic connector to your Pi but do not have room for yet another HAT.
SparkFun Qwiic SHIM for Raspberry Pi
Required Materials
To follow along with this tutorial, you will need the following materials. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.
Single Board Computer
You will need Raspberry Pi with 2x20 male headers installed.
A Pi Zero W will also work but you will need to make sure to solder some male headers to it.
Or you could connect it to any single board computer (like the NVIDIA Jetson Nano) that utilizes the 40-pin Raspberry Pi GPIO header footprint.
Qwiic Board
Now you probably wouldn't buy the Qwiic SHIM if you didn't have any Qwiic products to use with it, right? If you don't have any Qwiic products, the following might not be a bad place to start.
- SparkFun Micro OLED Breakout (Qwiic)
- SparkFun Atmospheric Sensor Breakout - BME280 (Qwiic)
- SparkFun Proximity Sensor Breakout - 20cm, VCNL4040 (Qwiic)
- SparkFun Qwiic Keypad - 12 Button
Finally, you'll need our handy Qwiic cables to easily connect sensors to your Qwiic SHIM. Below are a few options.
Required Setup Tools
If you are using your Pi (or other single-board computer) as a desktop, these peripherals are required:
- USB Mouse
- USB Keyboard
- HDMI monitor/TV
- 5V Power Supply
Suggested Reading
If you aren't familiar with the Qwiic system, we recommend reading here for an overview of everything Qwiic:
We would also recommend taking a look at the following tutorials if you aren't familiar with the content covered in them.
- I2C: An introduction to I2C, one of the main embedded communications protocols in use today.
- Serial Terminal Basics: This tutorial will show you how to communicate with your serial devices using a variety of terminal emulator applications.
- Raspberry Pi 3 Starter Kit Hookup Guide: Guide for getting going with the Raspberry Pi 3 Model B and Raspberry Pi 3 Model B+ starter kit.
- Getting Started with the Raspberry Pi Zero Wireless: Learn how to setup, configure, and use the smallest Raspberry Pi yet, the Raspberry Pi Zero - Wireless.
Hardware Overview
The Qwiic SHIM uses a unique friction-based connector that wedges itself onto the GPIO header for a secure, solderless connection. As you would expect, it has a single Qwiic connector that connects to your Pi's I2C bus (SDA, SCL, 5V and Ground). The SHIM also has a 3.3V regulator so it will work with all Qwiic devices.
Top View Photo of Qwiic SHIM
Press Fit Header
The Press Fit Header on the Qwiic SHIM allows you to easily place the Qwiic SHIM on to your Pi (or other Single-Board Computer with the Pi GPIO) aligning the square pin on the Qwiic SHIM with Pin 1 of your GPIO. Pin one on the GPIO can be identified by the square pin or the beveled corner on the silkscreen. We will cover that in more detail in the Hardware Hookup section.
Press Fit Header
Voltage Regulator
For you savvy readers out there, you may wonder why not just connect directly to the 3.3V rail on the Pi GPIO? A simple answer is the Pi's 5V rail is able to source more current than the 3.3V rail so the regulator allows you to connect more devices to the I2C bus without needing to worry about overtaxing your Pi. The on board AP2112K 3.3V regulator provides a clean 3.3V out for all attached Qwiic devices and can source up to 600mA@3.3V so you should have plenty of available current for your Qwiic project.
Voltage Regulator
Board Dimensions
Eagle File Photo with dimensions
Hardware Hookup
Getting started with the Qwiic SHIM is a snap (well, actually it's more like a push but you get the idea). Making sure to align the Qwiic SHIM's Pin 1 with Pin 1 on your Pi's GPIO header, press the Qwiic SHIM down onto the header. Pin 1 on both the Qwiic SHIM and the Pi GPIO will be marked with a square pin. There is also a beveled corner on the Pi GPIO header indicating Pin 1 from the top of your Pi. That's it! With the SHIM in place you can now attach all your Qwiic devices to your Pi with space to spare for other Pi HATs.
Warning! When connecting the Qwiic SHIM to your GPIO header, make sure to align it properly with Pin 1. If the Qwiic SHIM is not aligned properly (either if it is upside down or not aligned on the correct pins) you can short your 5V rail to Ground!
GPIO Configuration for old and new model Raspberry Pi from the Raspberry Pi GPIO Tutorial.
With your Qwiic SHIM mounted on your Pi it should look like this:
Qwiic SHIM mounted on a Pi 4
Qwiic SHIM mounted on a Pi Zero W
With the Qwiic SHIM in place, you can now stack all the HATs you would like on top. With a HAT on top of the SHIM, the press fit header will make an even better connection and the thin PCB allows any HAT to still connect fully to the GPIO header.
The Qwiic SHIM is seen here nicely wedged by the SparkFun Pulsed Radar Breakout
And here you can see it shoved in the middle with the SparkFun Pi Servo HAT.
Note: The Qwiic SHIM can also be connected in the same way with single board computers (like the NVIDIA Jetson Nano or the Google Coral) that utilize the 40-pin Raspberry Pi header footprint. Just remember to make sure you are aligning it properly!
Setting up I2C on Raspberry Pi
OS and Library Install
If you're starting from scratch, with a blank microSD card, you'll want to install Raspbian. If you've already got a working Raspbian system, skip ahead to step 3.
- Download the latest version of the NOOBS image. As of this writing, that is version 3.2.1.
- Follow the official installation instructions.
- Follow the Wiring Pi Instructions to get git, update and upgrade your Raspbian packages, then install WiringPi.
Be patient -- each of these steps takes a while.
Once you've got wiringPi installed, run the gpio commands shown below.
>gpio -v
>gpio readall
It should respond with some information about the wiringPi version and the Pi that its running on, then draw a table illustrating the configuration for the pins in the 40-pin connector.
Configuration
Like the SPI peripheral, I2C is not turned on by default. Again, we can use raspi-config to enable it.
- Run sudo raspi-config
- Use the down arrow to select 5 Interfacing Options
- Arrow down to P5 I2C
- Select yes when it asks you to enable I2C
- Select OK and then Finish
Once you return to terminal, enter this command:
>ls /dev/*i2c*
The Pi should respond with:
/dev/i2c-1
Which represents the user-mode I2C interface.
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.
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. Call i2cdetect -y 1 to probe the first I2C bus, which is what the Qwiic SHIM is connected to.
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. We can 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.
Resources and Going Further
For more information, check out the resources below:
But I Already Have Sensors!
If you already have a handful of SparkFun sensors and parts? SparkFun has been putting our standard GND/VCC/SDA/SCL pinout on all our I2C boards for many years. This makes it possible to attach a Qwiic Adapter that will get your SparkFun I2C sensor or actuator onto the Qwiic system.
Here is the list of the boards that have the standard I2C pinout and will work with the Qwiic adapter board:
- 9DoF Stick IMU - LSM9DS1
- 9DoF IMU - MPU-9250
- 6DoF IMU - LSM303C
- 6DoF IMU - LSM6DS3
- Triple Axis Accelerometer - LIS3DH
- Triple Axis Magnetometer - MAG3110
- Triple Axis Magnetometer - MLX90393
- Compass Module - HMC6343
- Atmospheric Sensor - BME280
- Barometric Pressure Sensor - MS5803-14BA
- Barometric Pressure Sensor - T5403
- Humidity and Temperature Sensor - Si7021
- Digital Temperature Sensor - TMP102
- Particle Sensor - MAX30105
- Air Quality Sensor - CCS811
- ToF Range Finder - VL6180
- Haptic Motor Driver - DRV2605L
- Micro OLED Display
- RGB and Gesture Sensor - APDS-9960
- RGB Light Sensor - ISL29125
- LED Driver - LP55231
- DAC Breakout - MCP4725
- 16 Output I/O Expander - SX1509
- Battery Babysitter - BQ24075
Check out this related tutorial:
Raspberry Pi SPI and I2C Tutorial
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.
Visit TechForum