Raspberry Pi

Installation

To install the Trellis python library on the Raspberry Pi follow these steps:
  • Make sure python 2.7 is installed on your Raspberry Pi. If you're using the Raspbian or Occidentalis operating system python should already be installed. However if you aren't sure, run the command 'python --version' (without quotes) at a terminal and look for an output like 'Python 2.7.3'.
  • If it isn't already enabled, follow this guide for information on setting up I2C on your Raspberry Pi.
  • Download the Adafruit Raspberry Pi Python code repository to your Raspberry Pi by following this guide.
  • Download the Trellis python library to the Raspberry Pi and unzip the archive. You can execute these commands to do both:
Download: file
wget https://github.com/tdicola/Adafruit_Trellis_Python/archive/master.zip
unzip master.zip
  • Install the library by navigating to the folder and executing setup.py:
Download: file
cd Adafruit_Trellis_Python-master
sudo python setup.py install
  • Note: For any python script you create to use Trellis, copy the Adafruit_I2C.py file from the Adafruit Raspberry Pi Python code download into the same folder as your python script. Don't skip this step--Adafruit_I2C.py needs to be in the same directory as your script or else the Trellis python library will fail to load!


Usage

The Raspberry Pi has one I2C bus on it's main GPIO header. This page has a great description of all the GPIO header pins, but as a summary you can use:

  • P1 pin 5 for SCL
  • P1 pin 3 for SDA

Connect Trellis power and ground to the Pi 5V power and ground pins respectively (P1 pin 2 or 4 for power, and P1 pin 6 for ground).

If you're using the Trellis INT wire as a key press interrupt, connect it to any digital GPIO pin on the Raspberry Pi. The Trellis python library doesn't use the interrupt pin directly, so you'll want to monitor the pin yourself in your code.

Finally to check the Trellis is detected and confirm which I2C bus it's on (different revisions of the Raspberry Pi have different I2C bus numbers), run these commands to probe each I2C bus:
Download: file
sudo i2cdetect -y -r 0
sudo i2cdetect -y -r 1
Trellis should be devices detected at addresses starting with 70, like 70, 71, 72, etc.
This guide was first published on Feb 13, 2014. It was last updated on Feb 13, 2014. This page (Raspberry Pi) was last updated on Jul 17, 2019.