SparkFun Qwiic Quad Solid State Relay Kit Hookup Guide

Pages
Contributors: El Duderino, Englandsaurus
Favorited Favorite 1

Qwiic Relay Python Package

Note: This example assumes you are using the latest version of Python 3. If this is your first time using Python or I2C hardware on a Raspberry Pi, please checkout our tutorial on Python Programming with the Raspberry Pi and the Raspberry Pi SPI and I2C Tutorial.

We've written a Python package to control the Qwiic Relay family including the Quad Solid State Relay Kit. You can install the sparkfun-qwiic-relay Python package hosted by PyPi. However, if you prefer to manually download and build the libraries from the GitHub repository, you can grab them here (*Please be aware of any package dependencies. You can also check out the repository documentation page, hosted on Read the Docs.):

Installation

Note: Don't forget to double check that the hardware I2C connection is enabled on your Raspberry Pi or other single board computer.

PyPi Installation

This repository is hosted on PyPi as the sparkfun-qwiic-relay package. On systems that support PyPi installation via pip3 (use pip for Python 2) is simple, using the following commands:

For all users (note: the user must have sudo privileges):

language:bash
sudo pip3 install sparkfun-qwiic-relay

For the current user:

language:bash
pip3 install sparkfun-qwiic-relay

Local Installation

To install, make sure the setuptools package is installed on the system.

Direct installation at the command line (use python for Python 2):

language:bash
python3 setup.py install

To build a package for use with pip3:

language:bash
python3 setup.py sdist

A package file is built and placed in a subdirectory called dist. This package file can be installed using pip3.

language:bash
cd dist
pip3 install sparkfun_qwiic_relay-<version>.tar.gz

Dependencies

This Python package has a few dependencies in the code, listed below:

language:python
from __future__ import print_function
import math
import qwiic_i2c

Function Overview

For a full overview of all the functions included with the Qwiic Relay Py package, head on over to the ReadtheDocs page.