Skip to main content

Simple tool for controlling USB bitbang relay boards.

Project description

bitbangrelay

CI pre-commit.ci status

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

License

Copyright (c) 2021-2022 SanCloud Ltd.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bitbangrelay-0.1.0.tar.gz (15.3 kB view hashes)

Uploaded Source

Built Distribution

bitbangrelay-0.1.0-py3-none-any.whl (17.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page