Manage GPIO lines in Python3 with libgpiod

Since linux 4.8 the GPIO sysfs interface is deprecated. User space should use the character device instead. libgpiod encapsulates the ioctl calls and data structures behind a straightforward API.

If you are using Debian Buster 10 install gpiod by typing these commands:

sudo apt update
sudo apt install python3-libgpiod

Blinking led

import gpiod
import time


lines = chip.get_lines([ 24 ])
lines.request(consumer='foobar', type=gpiod.LINE_REQ_DIR_OUT, default_vals=[ 0 ])

while True:
        lines.set_values([ 1 ])
        lines.set_values([ 0 ])


Sergio Tanzilli
System designer, webmaster and Acme Systems co-founder

Personal email:
Github repositories: and
Telegram group dedicated to the Acme Systems boards: