Step 1 - Plug in HAT

Now you have soldered the HAT up and you know how to power the servos, we can install the HAT

Begin by having the Pi shutdown and not powered, plug the HAT on top to match the 2x20 headers, and power up the Pi

Step 2. Configure your Pi to use I2C devices

To learn more about how to setup I2C with either Raspbian or Occidentalis, please take a minor diversion to this Adafruit Tutorial:

When you are ready to continue, enter the following commands to add SMBus support (which includes I2C) to Python:

sudo apt-get install python-smbus
sudo apt-get install i2c-tools

i2c-tools isn't strictly required, but it's a useful package since you can use it to scan for any I2C or SMBus devices connected to your board. If you know something is connected, but you don't know it's 7-bit I2C address, this library has a great little tool to help you find it. python-smbus is required, it adds the I2C support for python!

Don't forget you must add kernel support for I2C by following this tutorial!

You can then detect if the HAT is found on the #1 I2C port with:

sudo i2cdetect -y 1

This will search  /dev/i2c-1 for all address, and if an Adafruit PWM/Servo HAT is properly connected and it's set to its default address -- meaning none of the 6 address solder jumpers at the top of the board have been soldered shut -- it should show up at 0x40 (binary 1000000) as follows:

Once both of these packages have been installed, and i2cdetect finds the 0x40 I2C address, you have everything you need to get started accessing I2C and SMBus devices in Python.

This guide was first published on Jan 02, 2015. It was last updated on Apr 17, 2024.

This page (Attach & Test HAT/Bonnet) was last updated on Jan 02, 2015.

Text editor powered by tinymce.