Raspberry Pi Wiring & Test

The Raspberry Pi also has an I2C interface that can be used to communicate with this seesaw. You can use this breakout with the CircuitPython library and Python thanks to Adafruit_Blinka, our CircuitPython-for-Python compatibility library.

Install Python Software

You'll need to install the Adafruit_Blinka library that provides the CircuitPython library support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3.

Once that's done, from your command line run the following command:

  • sudo pip3 install adafruit-circuitpython-seesaw

If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

Enable I2C

We need to enable the I2C bus so we can communicate with the seesaw.

Download: file
sudo raspi-config

select Advanced options, enable I2C, and then finish.

With the Pi powered off, we can wire up the sensor to the Pi Cobbler like this:

  • Connect Vin to the 3V or 5V power supply (either is fine)
  • Connect GND to the ground pin on the Cobbler
  • Connect SDA (22)  to SDA on the Cobbler
  • Connect SCL (23) to SCL on the Cobbler
  • Connect the positive (long lead) of an LED to pin 15 on the samd09 breakout and the other lead to GND through a 1k ohm resistor.

You can also use direct wires, we happen to have a Cobbler ready. remember you can plug the cobbler into the bottom of the PiTFT to get access to all the pins!

Now you should be able to verify that the sensor is wired up correctly by asking the Pi to detect what addresses it can see on the I2C bus:

Download: file
sudo i2cdetect -y 1

It should show up under it's default address (0x49). If you don't see 49, check your wiring, did you install I2C support, etc?

Run example code

At long last, we are finally ready to run our example code. Open the Python REPL to begin.

First we'll import the necessary libraries, initialise the I2C bus and setup the LED pin for use:

Download: file
import time
import board
import busio
from adafruit_seesaw.seesaw import Seesaw

i2c_bus = busio.I2C(board.SCL, board.SDA)
ss = Seesaw(i2c_bus)

ss.pin_mode(15, ss.OUTPUT)

Now you're ready to blink the LED using digital_write:

Download: file
while True:
    ss.digital_write(15, True)
    time.sleep(1)
    ss.digital_write(15, False)
    time.sleep(1)

If everything is set up correctly, the LED attached to pin 15 on the SAMD09 breakout should blink on and off repeatedly. Press CTRL + C to stop the program running once you are satisfied with the blinking.

Documentation

See here for documentation of the seesaw CircuitPython API.

Full Example Code

# Simple seesaw test using an LED attached to Pin 15.
#
# See the seesaw Learn Guide for wiring details:
# https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout?view=all#circuitpython-wiring-and-test
import time

from board import SCL, SDA
import busio
from adafruit_seesaw.seesaw import Seesaw

i2c_bus = busio.I2C(SCL, SDA)

ss = Seesaw(i2c_bus)

ss.pin_mode(15, ss.OUTPUT)

while True:
    ss.digital_write(15, True)   # turn the LED on (True is the voltage level)
    time.sleep(1)                # wait for a second
    ss.digital_write(15, False)  # turn the LED off by making the voltage LOW
    time.sleep(1)
This guide was first published on Nov 01, 2017. It was last updated on Nov 01, 2017. This page (Raspberry Pi Wiring & Test) was last updated on Nov 16, 2019.