Skip to content

Commit 43d3d01

Browse files
Autogenerated. Convert PyPi packaging and add Readme Updates
1 parent a4cb76f commit 43d3d01

File tree

6 files changed

+166
-202
lines changed

6 files changed

+166
-202
lines changed

README.md

+99-96
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,145 @@
1-
Qwiic_Relay_Py
2-
==================
3-
<p align="center">
4-
<img src="https://cdn.sparkfun.com/assets/custom_pages/2/7/2/qwiic-logo-registered.jpg" width=200>
5-
<img src="https://www.python.org/static/community_logos/python-logo-master-v3-TM.png" width=240>
6-
</p>
7-
<p align="center">
8-
<a href="https://pypi.org/project/sparkfun-qwiic-relay/" alt="Package">
9-
<img src="https://img.shields.io/pypi/pyversions/sparkfun-qwiic-relay.svg" /></a>
10-
<a href="https://github.com/sparkfun/Qwiic_Relay_Py/issues" alt="Issues">
11-
<img src="https://img.shields.io/github/issues/sparkfun/Qwiic_Relay_Py.svg" /></a>
12-
<a href="https://sparkfun-qwiic-relay.readthedocs.io/en/latest/?" alt="Documentation">
13-
<img src="https://readthedocs.org/projects/sparkfun-qwiic-relay/badge/?version=latest&style=flat" /></a>
14-
<a href="https://github.com/sparkfun/Qwiic_Relay_Py/blob/master/LICENSE" alt="License">
15-
<img src="https://img.shields.io/badge/license-MIT-blue.svg" /></a>
16-
<a href="https://twitter.com/intent/follow?screen_name=sparkfun">
17-
<img src="https://img.shields.io/twitter/follow/sparkfun.svg?style=social&logo=twitter"
18-
alt="follow on Twitter"></a>
19-
20-
</p>
1+
![Qwiic RELAY - Python Package](docs/images/gh-banner.png "qwiic RELAY Python Package")
212

22-
<img src="https://cdn.sparkfun.com/assets/parts/1/5/7/5/4/16833-SparkFun_Qwiic_Quad_Solid_State_Relay_Kit-01.jpg" align="right" width=300 alt="SparkFun Qwiic Solid State Relay">
3+
# SparkFun Qwiic RELAY - Python Package
234

24-
Python module for the Qwiic Relays, Listed below
25-
* [SparkFun Qwiic Single Relay](https://www.sparkfun.com/products/15093)
26-
* [SparkFun Qwiic Quad Relay](https://www.sparkfun.com/products/15102)
27-
* [SparkFun Qwiic Quad Solid State Relay](https://www.sparkfun.com/products/16833)
28-
* [SparkFun Qwiic Dual Solid State Relay](https://www.sparkfun.com/products/16810)
5+
![PyPi Version](https://img.shields.io/pypi/v/sparkfun_qwiic_relay)
6+
![GitHub issues](https://img.shields.io/github/issues/sparkfun/qwiic_relay_py)
7+
![License](https://img.shields.io/github/license/sparkfun/qwiic_relay_py)
8+
![X](https://img.shields.io/twitter/follow/sparkfun)
9+
[![API](https://img.shields.io/badge/API%20Reference-blue)](https://docs.sparkfun.com/qwiic_relay_py/classqwiic__relay_1_1_qwiic_relay.html)
2910

30-
This package can be used in conjunction with the overall [SparkFun qwiic Python Package](https://github.com/sparkfun/Qwiic_Py)
11+
The SparkFun Qwiic Relay RELAY Module provides a simple and cost effective solution for adding Relay capabilities to your project. Implementing a SparkFun Qwiic I2C interface, these sensors can be rapidly added to any project with boards that are part of the SparkFun Qwiic ecosystem.
3112

32-
New to qwiic? Take a look at the entire [SparkFun qwiic ecosystem](https://www.sparkfun.com/qwiic).
13+
This repository implements a Python package for the SparkFun Qwiic RELAY. This package works with Python, MicroPython and CircuitPython.
3314

34-
## Contents
15+
### Contents
3516

36-
* [Supported Platforms](#supported-platforms)
37-
* [Dependencies](#dependencies)
17+
* [About](#about-the-package)
18+
* [Getting Started](#getting-started)
3819
* [Installation](#installation)
39-
* [Documentation](#documentation)
40-
* [Example Use](#example-use)
20+
* [Supported Platforms](#supported-platforms)
21+
* [Documentation](https://docs.sparkfun.com/qwiic_relay_py/classqwiic__relay_1_1_qwiic_relay.html)
22+
* [Examples](#examples)
23+
24+
## About the Package
25+
26+
This python package enables the user to access the features of the RELAY via a single Qwiic cable. This includes <setting relay state, reading relay state, set slow PWM value> and more. The capabilities of the RELAY are each demonstrated in the included examples.
27+
28+
New to qwiic? Take a look at the entire [SparkFun qwiic ecosystem](https://www.sparkfun.com/qwiic).
4129

42-
Supported Platforms
43-
--------------------
44-
The Qwiic Relay Python package current supports the following platforms:
45-
* [Raspberry Pi](https://www.sparkfun.com/search/results?term=raspberry+pi)
30+
### Supported SparkFun Products
4631

47-
Dependencies
48-
---------------
49-
This driver package depends on the qwiic I2C driver:
50-
[Qwiic_I2C_Py](https://github.com/sparkfun/Qwiic_I2C_Py)
32+
This Python package supports the following SparkFun qwiic products on Python, MicroPython and Circuit python.
5133

52-
Documentation
53-
-------------
54-
The SparkFun Qwiic Relay module documentation is hosted at [ReadTheDocs](https://sparkfun-qwiic-relay.readthedocs.io/en/latest/?)
34+
* [SparkFun Relay Sensor - RELAY](http://www.sparkfun.com/qwiic)
5535

56-
Installation
57-
-------------
36+
### Supported Platforms
5837

59-
### PyPi Installation
60-
This repository is hosted on PyPi as the [sparkfun-qwiic-relay](https://pypi.org/project/sparkfun-qwiic-relay/) package. On systems that support PyPi installation via pip, this library is installed using the following commands
38+
| Python | Platform | Boards |
39+
|--|--|--|
40+
| Python | Linux | [Raspberry Pi](https://www.sparkfun.com/raspberry-pi-5-8gb.html) , [NVIDIA Jetson Orin Nano](https://www.sparkfun.com/nvidia-jetson-orin-nano-developer-kit.html) via the [SparkFun Qwiic SHIM](https://www.sparkfun.com/sparkfun-qwiic-shim-for-raspberry-pi.html) |
41+
| MicroPython | Raspberry Pi - RP2, ESP32 | [SparkFun RP2040 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-rp2040.html), [SparkFun RP2350 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-rp2350.html), [SparkFun ESP32 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-esp32-wroom-usb-c.html)
42+
|CircuitPython | Raspberry Pi - RP2, ESP32 | [SparkFun RP2040 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-rp2040.html), [SparkFun RP2350 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-rp2350.html), [SparkFun ESP32 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-esp32-wroom-usb-c.html)
6143

62-
For all users (note: the user must have sudo privileges):
44+
> [!NOTE]
45+
> The listed supported platforms and boards are the primary platform targets tested. It is fully expected that this package will work across a wide variety of Python enabled systems.
46+
47+
## Installation
48+
49+
The first step to using this package is installing it on your system. The install method depends on the python platform. The following sections outline installation on Python, MicroPython and CircuitPython.
50+
51+
### Python
52+
53+
#### PyPi Installation
54+
55+
The package is primarily installed using the `pip3` command, downloading the package from the Python Index - "PyPi".
56+
57+
Note - the below instructions outline installation on a Linux-based (Raspberry Pi) system.
58+
59+
First, setup a virtual environment from a specific directory using venv:
6360
```sh
64-
sudo pip install sparkfun-qwiic-relay
61+
python3 -m venv path/to/venv
6562
```
66-
For the current user:
63+
You can pass any path as path/to/venv, just make sure you use the same one for all future steps. For more information on venv [click here](https://docs.python.org/3/library/venv.html).
6764

65+
Next, install the qwiic package with:
6866
```sh
69-
pip install sparkfun-qwiic-relay
67+
path/to/venv/bin/pip3 install sparkfun-qwiic-relay
68+
```
69+
Now you should be able to run any example or custom python scripts that have `import qwiic_relay` by running e.g.:
70+
```sh
71+
path/to/venv/bin/python3 example_script.py
7072
```
7173

72-
### Local Installation
73-
To install, make sure the `setuptools` package is installed on the system.
74+
### MicroPython Installation
75+
If not already installed, follow the [instructions here](https://docs.micropython.org/en/latest/reference/mpremote.html) to install mpremote on your computer.
7476

75-
Direct installation at the command line:
77+
Connect a device with MicroPython installed to your computer and then install the package directly to your device with mpremote mip.
7678
```sh
77-
python setup.py install
79+
mpremote mip install github:sparkfun/qwiic_relay_py
7880
```
7981

80-
To build a package for use with pip:
82+
If you would also like to install the examples for this repository, issue the following mip command as well:
8183
```sh
82-
python setup.py sdist
83-
```
84-
A package file is built and placed in a subdirectory called dist. This package file can be installed using pip.
84+
mprmeote mip install github:sparkfun/qwiic_relay_py@examples
85+
```
86+
87+
### CircuitPython Installation
88+
If not already installed, follow the [instructions here](https://docs.circuitpython.org/projects/circup/en/latest/#installation) to install CircUp on your computer.
89+
90+
Ensure that you have the latest version of the SparkFun Qwiic CircuitPython bundle.
91+
```sh
92+
circup bundle-add sparkfun/Qwiic_Py
93+
```
94+
95+
Finally, connect a device with CircuitPython installed to your computer and then install the package directly to your device with circup.
8596
```sh
86-
cd dist
87-
pip install sparkfun_qwiic_relay-<version>.tar.gz
88-
97+
circup install --py qwiic_relay
8998
```
99+
100+
If you would like to install any of the examples from this repository, issue the corresponding circup command from below. (NOTE: The below syntax assumes you are using CircUp on Windows. Linux and Mac will have different path seperators (i.e. "/" vs. "\"). See the [CircUp "example" command documentation](https://learn.adafruit.com/keep-your-circuitpython-libraries-on-devices-up-to-date-with-circup/example-command) for more information)
101+
102+
```sh
103+
circup example qwiic_relay\qwiic_relay_ex1_single
104+
circup example qwiic_relay\qwiic_relay_ex2_dual
105+
circup example qwiic_relay\qwiic_relay_ex3_quad
106+
circup example qwiic_relay\qwiic_relay_ex4_pwm
107+
```
108+
90109
Example Use
91110
---------------
92-
See the examples directory for more detailed use examples.
111+
Below is a quickstart program to print readings from the RELAY.
112+
113+
See the examples directory for more detailed use examples and [examples/README.md](https://github.com/sparkfun/qwiic_relay_py/blob/main/examples/README.md) for a summary of the available examples.
93114

94115
```python
95-
from __future__ import print_function
116+
96117
import qwiic_relay
97118
import time
98119
import sys
99120

100-
myRelays = qwiic_relay.QwiicRelay()
121+
myRelay = qwiic_relay.QwiicRelay(qwiic_relay.SINGLE_RELAY_DEFUALT_ADDR)
101122

102123
def runExample():
124+
print("\nSparkFun Qwiic Relay Example 1 - Single\n")
103125

104-
print("\nSparkFun Qwiic Relay Example 1\n")
105-
106-
if myRelays.begin() == False:
126+
if myRelay.begin() == False:
107127
print("The Qwiic Relay isn't connected to the system. Please check your connection", \
108128
file=sys.stderr)
109129
return
110130

111-
#Turn on relays one and three
112-
myRelays.set_relay_on(1)
113-
myRelays.set_relay_on(3)
114-
time.sleep(1)
115-
116-
#Print the status of all relays
117-
for relayNum in range(4):
118-
current_status = None
119-
if myRelays.get_relay_state(relayNum) is True:
120-
current_status = "On"
121-
else:
122-
current_status = "Off"
123-
print("Status 1: " + current_status + "\n")
124-
125-
#Turn off 1 and 3, turn on 2 and 4
126-
myRelays.set_relay_off(1)
127-
myRelays.set_relay_on(2)
128-
myRelays.set_relay_off(3)
129-
myRelays.set_relay_on(4)
130-
time.sleep(1)
131-
131+
for i in range(2):
132+
myRelay.set_relay_on()
132133

133-
#Turn all relays on, then turn them all off
134-
myRelays.set_all_relays_on()
135-
time.sleep(1)
136-
137-
myRelays.set_all_relays_off()
138-
134+
print("Relay state: " + str(myRelay.get_relay_state()))
135+
136+
time.sleep(1)
137+
138+
myRelay.set_relay_off()
139+
140+
print("Relay state: " + str(myRelay.get_relay_state()))
139141

142+
time.sleep(1)
140143

141144
if __name__ == '__main__':
142145
try:

docs/images/gh-banner.png

537 KB
Loading

examples/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Sparkfun RELAY Examples Reference
2+
Below is a brief summary of each of the example programs included in this repository. To report a bug in any of these examples or to request a new feature or example [submit an issue in our GitHub issues.](https://github.com/sparkfun/qwiic_relay_py/issues).
3+
4+
NOTE: Any numbering of examples is to retain consistency with the Arduino library from which this was ported.
5+
6+
## Qwiic Relay Ex1 Single
7+
Example that shows the basics of using the single relay.
8+
9+
## Qwiic Relay Ex2 Dual
10+
Example that shows the basics of using the dual relays.
11+
12+
## Qwiic Relay Ex3 Quad
13+
Example that shows the basics of using the quad relays.
14+
15+
## Qwiic Relay Ex4 Pwm
16+
Example that shows how to set and get the slow PWM value
17+
18+

pyproject.toml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
4+
[project]
5+
name = "sparkfun_qwiic_relay"
6+
version = "0.1.0"
7+
description = long_description
8+
readme = "DESCRIPTION.rst"
9+
10+
authors = [{name="Sparkfun Electronics", email="[email protected]"}]
11+
dependencies = ["sparkfun_qwiic_i2c"]
12+
13+
classifiers=[
14+
# How mature is this project? Common values are
15+
# 3 - Alpha
16+
# 4 - Beta
17+
# 5 - Production/Stable
18+
"Development Status :: 5 - Production/Stable",
19+
20+
# Indicate who your project is intended for
21+
"Intended Audience :: Developers",
22+
"Topic :: Software Development :: Build Tools",
23+
24+
# Pick your license as you wish (should match "license" above)
25+
"License :: OSI Approved :: MIT License",
26+
27+
# Specify the Python versions you support here. In particular, ensure
28+
# that you indicate whether you support Python 2, Python 3 or both.
29+
"Programming Language :: Python :: 3.5",
30+
"Programming Language :: Python :: 3.6",
31+
"Programming Language :: Python :: 3.7",
32+
"Programming Language :: Python :: 3.8",
33+
"Programming Language :: Python :: 3.9",
34+
"Programming Language :: Python :: 3.10",
35+
"Programming Language :: Python :: 3.11",
36+
"Programming Language :: Python :: 3.12",
37+
"Programming Language :: Python :: 3.13",
38+
"Programming Language :: Python :: 3.14",
39+
"Programming Language :: Python :: Implementation :: MicroPython",
40+
# NOTE: CircuitPython is also supported, but no classifier exists for it
41+
]
42+
43+
keywords = ["electronics, maker"]
44+
45+
[project.urls]
46+
homepage = "http://www.sparkfun.com/qwiic"
47+
48+
[tool.setuptools]
49+
py-modules = ["qwiic_relay"]

setup.cfg

-2
This file was deleted.

0 commit comments

Comments
 (0)