Skip to main content

This module provides device classes for controlling the gpio ports

Project description

rpi-gpio-devices

Control Raspberry Pi gpio pins more easily.

This module provides an abstraction layer to control connected devices (fans, switches, LEDs, buttons) more easily with ready to use device classes and functions.

It uses the RPi.GPIO module to control the GPIO pins. Currently this is the recommended module to use for archlinuxarm, but it only provides basic functions to manipulate the pins.

Installation

pip install rpi-gpio-devices

pypi

Few examples

Automatic fan control based on CPU temp

from time import sleep

from rpi_gpio_devices import Fan

# Basic usage
pwm_fan = Fan(power=29, sense=35, pwm=33)

try:
    while True:
        pwm_fan.auto_set()
except KeyboardInterrupt:
    pwm_fan.cleanup()

Set LED brightness with PWM

from time import sleep

from rpi_gpio_devices import PWMLED

pwmled = PWMLED(33)

pwmled.set_brightness(50)
sleep(2)
pwmled.set_brightness(100)
sleep(2)
pwmled.set_brightness(0)
# pwmled.turn_off() # Or simply just turn it off

pwmled.cleanup()

Check if a button is pressed

from time import sleep

from rpi_gpio_devices import Button

button = Button(11)

try:
    while True:
        if button.is_pressed():
            print('Button is pressed!')
        sleep(0.5)
except KeyboardInterrupt:
    button.cleanup()

More in the examples directory.

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

rpi_gpio_devices-2.0.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

rpi_gpio_devices-2.0.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file rpi_gpio_devices-2.0.1.tar.gz.

File metadata

  • Download URL: rpi_gpio_devices-2.0.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for rpi_gpio_devices-2.0.1.tar.gz
Algorithm Hash digest
SHA256 89b2ad9f5e917eea8474f3bbb5f4691399c564b45f9a48fd9f0ff51846243cbf
MD5 652e81a485503243d360b939cf529baf
BLAKE2b-256 e0b6fbe43b03e2045da5b366055ce06c0e3b36396d6dec700bec2129506fee85

See more details on using hashes here.

File details

Details for the file rpi_gpio_devices-2.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for rpi_gpio_devices-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f1c2dbaf948ddc95e350e5c1bb384b6a164f79e0251567462c151cd1b1f8f4e3
MD5 d46914f58a4254d5f4ab3b77c1aee351
BLAKE2b-256 ae6ebad7e869f354394244dac2a866c4a67a1fed11d9d773cad34847ab4d4e98

See more details on using hashes here.

Supported by

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