This Qwiic HAT for Raspberry Pi is the quickest and easiest way to utilize SparkFun’s Qwiic ecosystem while still using that Raspberry Pi that you’ve come to know and love. This Qwiic HAT connects the I2C bus (GND, 3.3V, SDA, and SCL) on your Raspberry Pi to an array of Qwiic connectors. It also has a few important pins on the Raspberry Pi broken out for easy access. Since the Qwiic system allows for daisy chaining (as long as your devices are on different addresses), you can stack as many sensors as you’d like to create a tower of sensing power!
To follow along with this hookup guide, you will need any Raspberry Pi with 2×20 male headers.
A Pi Zero W will also work but you will need to make sure to solder some male headers to it.
Now you probably didn’t buy the Qwiic HAT 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.
Finally, you’ll need our handy Qwiic cables to easily connect sensors to your Qwiic HAT. Below are a few options.
Required Setup Tools
As a desktop, these devices are required:
- USB Mouse
- USB Keyboard
- HDMI monitor/TV/adapted VGA
- 5V Power Supply
If you aren’t familiar with our new Qwiic system, we recommend reading here for an overview. We would also recommend taking a look at the following tutorials if you aren’t familiar with them.
An introduction to I2C, one of the main embedded communications protocols in use today.
The Qwiic HAT has 4 Qwiic connect ports, all on the same I2C bus. In addition to this, some of the pins on the Raspberry Pi are broken out for the user.
To get started with your Qwiic HAT, simply plug it into the headers on the Raspberry Pi, make sure that the “USB” arrow on the HAT is pointing towards the USB on the Raspberry Pi.
Once the HAT is plugged in, you can start plugging in any Qwiic enabled sensors you might have.
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 NOOBS image. As of this writing, it’s at version 2.4.4.
- Follow the official installation instructions.
- Follow the Wiring Pi Instructions to get git, update and upgrade your Rasbpian 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.
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.
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
The Pi should respond with
Which represents the user-mode I2C interface.
Read More Info…