SparkFun Qwiic Dual Solid State Relay Hookup Guide
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 Qwiic Dual Solid State Relay. You can install the
sparkfun-qwiic-relay Python package hosted by PyPi through a command interface. If you prefer to manually download and build the libraries from the GitHub repository, you can download the package by clicking the button below:
(*Please be aware of any package dependencies. You can also check out the repository documentation page, hosted on Read the Docs.)
Note: Don't forget to double check that the hardware I2C connection is enabled on your Raspberry Pi or other single board computer. The Raspberry Pi tutorials linked in the note above cover how to enable the Pi's I2C bus.
This repository is hosted on PyPi as the
sparkfun-qwiic-relay package. On systems that support PyPi installation via
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
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
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
language:bash cd dist pip3 install sparkfun_qwiic_relay-<version>.tar.gz
This Python package has a few dependencies in the code, listed below:
language:python from __future__ import print_function import math import qwiic_i2c
For a full overview of all the functions included with the Qwiic Relay Py package, head on over to the ReadtheDocs page.