Simple tool for controlling USB bitbang relay boards.
Project description
bitbangrelay
A simple tool for controlling USB relay boards based around an FTDI FT232R/FT245R chip in bitbang mode, for example SainSmart 4 or 8 channel USB relay modules.
NOTE: This project is a work in progress, documentation and testing are currently very limited. If this project is useful to you, please let us know how it can be improved.
Install
There has not yet been a packaged release of bitbangrelay, so the best way to install is via git:
pip install git+https://github.com/SanCloudLtd/bitbangrelay.git
Dependencies
bitbangrelay relies on the following Python modules:
-
PyYAML for config file parsing.
-
pylibftdi for interacting with FTDI devices.
- Note that the C library libftdi must be installed separately for pylibftdi to import correctly.
Usage
usage: bitbangrelay [-h] [--version] [-c CONFIG_FILE] [-d DEVICE] channel action
USB BitBang Relay Controller
positional arguments:
channel Relay channel to control
action Action to perform: 'on', 'off' or 'cycle'
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
-c CONFIG_FILE, --config-file CONFIG_FILE
Config file to load, defaults to ~/.config/bitbangrelay.yml
-d DEVICE, --device DEVICE
Relay device to control, defaults to 'default'
Example usage
-
To turn on a channel:
bitbangrelay bbe on
-
To turn off a channel:
bitbangrelay bbe off
-
To power cycle a channel:
bitbangrelay bbe cycle
- The connected device will be powered off and then 5 seconds later it will be powered back on.
-
To turn off all channels of a relay:
bitbangrelay all off
Configuration
The bitbangrelay library parses a configuration file in yaml syntax to determine the available relay devices and channels.
Example configuration:
# Top level keys give names for the available relay devices. A relay device
# named "default" will be the default if no other device name is given.
default:
# The id is required for each relay device. This is passed to pylibftdi
# to select the appropriate USB device and is typically the device's
# serial number.
id: AAAAAAAA
# The number of channels supported by the relay device. If this is not
# provided then it is assumed that 8 channels are available.
channels: 4
# Channels can be selected by index or by alias. A dictionary mapping
# alises to channel numbers may be provided for convenience.
aliases:
bbe: 0
bbe-lite: 1
beaglebone-black: 2
raspberrypi4: 3
Maintainers
- Paul Barker :envelope:
License
Copyright (c) 2021-2022 SanCloud Ltd.
-
Code files are distributed under the Apache 2.0 License.
-
Documentation files are distributed under the CC BY 4.0 License.
-
Trivial data files are distributed under the CC0 1.0 License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for bitbangrelay-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc5c1fdd3ac080d4da3496eb06c6d76226e0cb6a425a9e63527ad1f85ca1e065 |
|
MD5 | 6c4dc6c65ba8fc76dadb5902b9cf62fc |
|
BLAKE2b-256 | ddf87b3e709f73006242b2e291871d82fa0f6bd8a82ce9b49fcfe2e720d550f2 |