Skip to main content

gpiod Driver

jumpstarter-driver-gpiod provides functionality for interacting with gpiod GPIO pins for digital input/output operations.

This requires the /dev/gpiochip[0..N] device available on the system, and you can use the gpioinfo gpiod tool to list the available GPIO lines.

Installation

:substitutions:
$ pip3 install --extra-index-url {{index_url}} jumpstarter-driver-gpiod

Hardware Requirements

  • gpiod with GPIO access
  • Python gpiod library installed
  • Appropriate permissions to access /dev/gpiochip0

Configuration

The gpiod driver provides three main driver types:

DigitalOutput Configuration

Example configuration for digital output:

export:
  led_output:
    type: jumpstarter_driver_gpiod.driver.DigitalOutput
    config:
      device: "/dev/gpiochip0"
      line: 18
      drive: "push_pull"
      active_low: false
      bias: "pull_up"
      initial_value: "inactive"

DigitalInput Configuration

Example configuration for digital input:

export:
  button_input:
    type: jumpstarter_driver_gpiod.driver.DigitalInput
    config:
      line: 17
      active_low: false
      bias: "pull_up"

PowerSwitch Configuration

Example configuration for power switching:

export:
  power_switch:
    type: jumpstarter_driver_gpiod.driver.PowerSwitch
    config:
      line: 18
      mode: "push_pull"
      active_low: false
      bias: "pull_up"
      initial_value: "inactive"

Config parameters

Parameter Description Type Required Default Driver Types
device The GPIO device to use (can be integer or string like "/dev/gpiochip0") str no "/dev/gpiochip0" All
line The GPIO line number to use int yes All
drive The drive mode for the GPIO line. Options: "push_pull", "open_drain", "open_source" str no null DigitalOutput, PowerSwitch
active_low Whether the pin is active low (True) or active high (False) bool no False All
bias The bias configuration for the GPIO line. Options: "as_is", "pull_up", "pull_down", "disabled" str no null All
initial_value The initial value for output pins. Options: "active", "inactive", "on", "off", True, False str/bool no "inactive" DigitalOutput, PowerSwitch
mode The mode for PowerSwitch (same as drive parameter) str no "push_pull" PowerSwitch

Usage

Digital Output Examples

Basic LED control:

# Turn LED on
led_output.on()

# Turn LED off
led_output.off()

# Read current state
state = led_output.read()
print(f"LED state: {state}")

Digital Input Examples

Button input with edge detection:

# Read current input state
state = button_input.read()
print(f"Button state: {state}")

# Wait for button press (active state)
button_input.wait_for_active(timeout=10.0)

# Wait for button release (inactive state)
button_input.wait_for_inactive(timeout=10.0)

# Wait for rising edge (button press)
button_input.wait_for_edge("rising", timeout=10.0)

# Wait for falling edge (button release)
button_input.wait_for_edge("falling", timeout=10.0)

Power Switch Examples

Power control for devices:

# Turn power on
power_switch.on()

# Turn power off
power_switch.off()

# Read current power state
state = power_switch.read()
print(f"Power state: {state}")

Pin Configuration Details

Drive Modes

  • push_pull: Standard push-pull output (default)
  • open_drain: Open-drain output (useful for I2C, etc.)
  • open_source: Open-source output

Bias Configuration

  • as_is: No bias (default)
  • pull_up: Internal pull-up resistor
  • pull_down: Internal pull-down resistor
  • disabled: Disable bias

Active Low vs Active High

  • active_low: false (default): Pin is active when HIGH
  • active_low: true: Pin is active when LOW

Initial Values

For output pins, you can set the initial state:

  • "inactive" or "off" or False: Start with pin LOW
  • "active" or "on" or True: Start with pin HIGH

API Reference

DigitalOutputClient

.. autoclass:: jumpstarter_driver_gpiod.client.DigitalOutputClient()
    :members: on, off, read

DigitalInputClient

.. autoclass:: jumpstarter_driver_gpiod.client.DigitalInputClient()
    :members: wait_for_active, wait_for_inactive, wait_for_edge, read
  • Timeout conditions for input operations

Release files for jumpstarter-driver-gpiod 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jumpstarter-driver-gpiod 0.9.0
File Size Uploaded
jumpstarter_driver_gpiod-0.9.0.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jumpstarter-driver-gpiod 0.9.0
File Interpreter ABI Platform
jumpstarter_driver_gpiod-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.1 kB

Release files / jumpstarter_driver_gpiod-0.9.0.tar.gz

Download URL jumpstarter_driver_gpiod-0.9.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
22d316a586f7759b339fb3c60708ecf9709a173f559f5e5664ba6ba2f88360d9
BLAKE2b-256 checksum
How to use checksums
c39ca4d2b9c66bf9765cd4d56677f42d57cf6c7fb3c04c16f84e190dbf7b8970
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.22

Release files / jumpstarter_driver_gpiod-0.9.0-py3-none-any.whl

Download URL jumpstarter_driver_gpiod-0.9.0-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ef619aa2a4382a2bc3b43c9fe2140d1941fec4df2238e27efbf491a6ba80987
BLAKE2b-256 checksum
How to use checksums
73ffb048ea8da517ae4499fe0a6f04660e56b53062dc505b7b55d60e946e8be9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.22

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files

0.8.1

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page