Pi Prep

Update Your Pi to the Latest Raspbian

Your Pi will need to be running the latest version of Raspbian. This tutorial was written using Raspbian Buster (July 2019). Checkout our guide for Preparing an SD Card for your Raspberry Pi if you have not done so already. After the installation is complete be sure and run the following commands to make confirm your installation packages are up to date. 

Download: file
sudo apt-get update -y
sudo apt-get upgrade -y

Install adafruit-blinka

Run the following command to install the adafruit_blinka CircuitPython Libraries.

Download: file
pip3 install adafruit-blinka

Enable the I2C Interface

The Holtek HT16K33 chip used in all of our backpacks communicates using the common I2C bus.  The I2C bus allows multiple devices to be connected to your Raspberry Pi, each with a unique address, that can often be set by changing jumper settings on the module. Linux and the Pi both have native support for I2C, but you'll need to run through a couple quick steps from the console before you can use it in Python.  

To see a detailed screen by screen tutorial about how to setup I2C with Raspbian, take a minor diversion to this Adafruit Tutorial: Raspberry Pi Lesson 4. GPIO Setup. We will provide a brief summary below for those somewhat familiar with the raspi-config utility.

Download: file
sudo raspi-config
<Interfacing Options>
<I2C> Enable/Disable
<Enable>
<Back>
<Finish>

Test the I2C Bus

Now that our Pi has rebooted we can confirm that the correct I2C modules have loaded with the following command.

Download: file
lsmod | grep -i i2c
Download: file
sudo i2cdetect -y 1

This will search I2C for all address, and if a Holtek HT16K33 breakout is properly connected and it's set to it's default address it should show up as follows (the exact address will vary depending on whether or not you have any of the address solder jumpers set).

If you happen to have one of the original first batch of Raspberry Pis, you will need to change the 1 to a 0 in the command above.

Recent Raspbian releases includes the i2cdetect command, but if it is not found on your system please use the following syntax to install the necessary packages.

Download: file
sudo apt-get install -y python-smbus i2c-tools

Install the HT16K33 Library

The software for this project uses the Adafruit code for driving the 7-segment and matrix displays.

Download: file
pip3 install adafruit-circuitpython-ht16k33
This guide was first published on Aug 24, 2012. It was last updated on Aug 24, 2012. This page (Pi Prep) was last updated on Sep 21, 2019.