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.

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:

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:

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:

while True:
    ss.digital_write(15, True)
    ss.digital_write(15, False)

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.


See here for documentation of the seesaw CircuitPython API.

Full Example Code

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

# Simple seesaw test using an LED attached to Pin 15.
# See the seesaw Learn Guide for wiring details:
import time

import board
from adafruit_seesaw.seesaw import Seesaw

i2c_bus = board.I2C()  # uses board.SCL and board.SDA
# i2c_bus = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller

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

This guide was first published on Nov 01, 2017. It was last updated on Jun 18, 2024.

This page (Raspberry Pi Wiring & Test) was last updated on Jun 18, 2024.

Text editor powered by tinymce.