Raspberry Pi GPIO Library Comparison (Pi 5): Speed Tested Examples

In this tutorial, we’ll compare every popular Raspberry Pi GPIO library: gpiozero, RPi.GPIO, lgpio, libgpiod, pigpio, and WiringPi. You’ll learn which ones work on the Raspberry Pi 5, how to install each one, and how to blink an LED, read an input, and catch an edge with each of them in Python and C/C++, with the same circuit and the same task for every library.

We’ll answer the question: which Raspberry Pi 5 GPIO library should you use, and what changed compared to the Raspberry Pi 4 and older boards. You’ll see the real error messages of the libraries that fail on the Pi 5, and my oscilloscope measurements of each library’s GPIO toggle speed, CPU use, memory, and start-up time. Without further ado, let’s get right into it!

Note: All examples in this tutorial are tested with: Raspberry Pi 5 (8GB) with Raspberry Pi OS (64-bit) Trixie.

This tutorial assumes your Raspberry Pi is set up with Raspberry Pi OS and reachable over SSH. If it isn’t, follow the Raspberry Pi Setup Guide first.

Raspberry Pi GPIO Library Comparison Table

On the Raspberry Pi 5, use gpiozero for Python and libgpiod for C and C++. Both are part of Raspberry Pi OS, use the kernel’s GPIO interface, and need no sudo. This table sums up all six libraries as they ran on my Raspberry Pi 5:

LibraryWorks on Pi 5?LanguagesPre-installed?Toggle Speed (Measured)Best For
gpiozeroYesPythonYes131kHzNew Python projects
RPi.GPIOYes, through rpi-lgpioPythonYes (rpi-lgpio)129kHzRunning existing RPi.GPIO code
lgpioYesPython, CYes (C header: liblgpio-dev)458kHz (Python), 781kHz (C)Pin-level control, I2C/SPI helpers
libgpiod v2YesC, C++, PythonYes (headers: libgpiod-dev)870kHz (C), 792kHz (C++), 298kHz (Python)New C and C++ projects
pigpioNoPython, CNo (no daemon package)–Raspberry Pi 4 and older only
WiringPi 3Yes (since v3.0)CNo (.deb from GitHub)20.0MHzThe fastest bit-banging in C

Here is the same small job in the two recommended libraries: blink the LED on GPIO17 (pin 11) three times.

Python Code example (gpiozero)

C++ Code example (libgpiod v2)

The rest of this tutorial explains why some libraries fail on the Raspberry Pi 5, shows the complete test for each library with its real output, and compares their measured speed, CPU use, and memory.


Which Raspberry Pi GPIO Library Should You Use?

The right Raspberry Pi GPIO library depends on your language and on the code you already have. This chart sums up my recommendation for the Raspberry Pi 5:

Which Raspberry Pi GPIO library to use on the Raspberry Pi 5: gpiozero, RPi.GPIO via rpi-lgpio, libgpiod v2, WiringPi, lgpio, pigpio decision chart

  • New Python project: gpiozero. Its LED, Button, and PWMLED classes need the least code, and it’s pre-installed.
  • Existing RPi.GPIO code: keep import RPi.GPIO. Raspberry Pi OS runs it on rpi-lgpio, so most scripts work unchanged. Move to gpiozero when you rewrite them.
  • C or C++ program: libgpiod v2. It’s the official Linux GPIO interface and works on every Raspberry Pi model.
  • Maximum speed in C: WiringPi 3. It writes the RP1 registers directly and toggled a pin at 20.0MHz, 23 times faster than libgpiod.
  • Old pigpio code: port it. pigpio doesn’t run on the Raspberry Pi 5; lgpio, from the same author, has the closest API.

Raspberry Pi 5 GPIO Software Stack Explained

A Raspberry Pi GPIO library reaches the pins in one of two ways: through the Linux kernel’s GPIO character device ( /dev/gpiochip0), or by writing the GPIO registers directly through a memory map ( /dev/gpiomem). On the Raspberry Pi 5 this choice decides whether a library works at all.

Raspberry Pi 5 GPIO software stack: gpiozero, RPi.GPIO (rpi-lgpio), lgpio and libgpiod use /dev/gpiochip0, WiringPi 3 writes RP1 registers through /dev/gpiomem0, the original RPi.GPIO and pigpio expect the BCM283x GPIO block

On the Raspberry Pi 4 and older boards, the 40-pin header is wired to the GPIO block inside the Broadcom SoC. The original RPi.GPIO and pigpio map that block into memory and write its registers, which is fast and simple. On the Raspberry Pi 5, the header pins belong to the RP1 I/O controller, a separate chip connected to the BCM2712 SoC over PCIe. A library that writes the old Broadcom registers changes nothing on the header, so the original RPi.GPIO stops with an error and pigpio was never ported, per the Raspberry Pi white paper RP-006553-WP and pigpio issue #589.

The libraries that go through the kernel don’t care which chip holds the pins. gpiozero (with its lgpio pin factory), rpi-lgpio, lgpio, and libgpiod all open /dev/gpiochip0, which on the Pi 5 is the pinctrl-rp1 driver, and the kernel writes the RP1 registers for them. WiringPi 3 is the exception on the direct path: since version 3.0 (2024) it knows the RP1 register map and writes it through /dev/gpiomem0. For the pin numbers and alternate functions of the header itself, see the Raspberry Pi 5 Pinout guide.


Raspberry Pi GPIO Library Test Setup

Every library in this tutorial runs the same task on the same circuit, so the results compare directly:

  1. Blink the LED on GPIO17 three times.
  2. Read GPIO24 while GPIO23 drives it HIGH and LOW through a jumper wire.
  3. Catch edges: send 5 pulses on GPIO23 and count the rising edges on GPIO24 with the library’s callback or event API.

These are the parts for the test circuit:

QTY.Component NameAmazon.comAliExpress
1Raspberry Pi 5 (4GB or 8GB)AmazonAliExpress
1Raspberry Pi 27W USB-C Power SupplyAmazonAliExpress
15mm LED (Yellow)AmazonAliExpress
1330Ω ResistorAmazonAliExpress
1BreadboardAmazonAliExpress
1Jumper Wires (Female-Male and Female-Female)AmazonAliExpress

I used the same breadboard as in my Raspberry Pi GPIO tutorial. Its push button on GPIO27 isn’t used in this comparison.

Raspberry Pi 5 GPIO library test circuit wiring diagram: LED with 330 ohm resistor on GPIO17 (pin 11), push button on GPIO27 (pin 13) and a GPIO23 to GPIO24 jumper

Raspberry Pi 5 Breadboard Pin 9 (GND) LED cathode, Push Button Pin 11 (GPIO17) 330Ω → LED anode Pin 13 (GPIO27) Push Button (not used here) Pin 16 (GPIO23) Pin 18 (GPIO24)

The LED’s long leg goes to the 330Ω resistor on GPIO17 and its short leg to GND. One jumper wire connects GPIO23 to GPIO24, so a program can drive one pin and read the other back. The oscilloscope’s channel 1 probe sits on GPIO17 for the speed test.

GND (pin 9) goes to the breadboard’s ground rail, which connects the LED’s cathode and the push button.

GPIO17 (pin 11) drives the LED through the 330Ω resistor, and is the pin measured on the oscilloscope.

GPIO27 (pin 13) goes to the push button from the GPIO tutorial. It stays wired but isn’t used in this comparison.

GPIO23 (pin 16) connects to GPIO24 (pin 18) with one jumper: GPIO23 is the output, GPIO24 the input.


gpiozero on the Raspberry Pi 5 (Python)

gpiozero works on the Raspberry Pi 5 out of the box: it’s pre-installed on Raspberry Pi OS (version 2.0.1) and uses the lgpio pin factory on the Pi 5. Instead of pin calls, you create objects for the parts you wire up ( LED, Button, PWMLED, DigitalInputDevice). The gpiozero documentation lists all of them. On an image without it, install it with sudo apt install python3-gpiozero.

Here is The Test Code For gpiozero (gpiozero_demo.py)

Python Code example (gpiozero)

This is the real output on my Raspberry Pi 5. The pin factory is LGPIOFactory, the jumper reads back correctly, and the when_activated callback saw all 5 rising edges:

gpiozero test output on the Raspberry Pi 5: LGPIOFactory, blink, GPIO24 read and 5 rising edges
gpiozero test output on the Raspberry Pi 5: LGPIOFactory, blink, GPIO24 read and 5 rising edges

gpiozero Pin Factories on the Raspberry Pi 5

A gpiozero pin factory is the low-level library gpiozero uses underneath. On the Raspberry Pi 5, two of the four factories work. I created LED(17) with each factory in turn ( factory_test.py in the download):

Pin FactoryLibrary UnderneathRaspberry Pi 5 Result
LGPIOFactorylgpioWorks (the default)
RPiGPIOFactoryRPi.GPIO (rpi-lgpio on Raspberry Pi OS)Works
PiGPIOFactorypigpio daemonOSError: failed to connect to localhost:8888
NativeFactorydirect Broadcom registersOSError: unable to open /dev/gpiomem or /dev/mem; upgrade your kernel or run as root
gpiozero pin factories on the Raspberry Pi 5: LGPIOFactory and RPiGPIOFactory work, PiGPIOFactory and NativeFactory fail
gpiozero pin factories on the Raspberry Pi 5: LGPIOFactory and RPiGPIOFactory work, PiGPIOFactory and NativeFactory fail

Older tutorials set GPIOZERO_PIN_FACTORY=pigpio for remote GPIO or better PWM timing. On the Raspberry Pi 5 that line breaks the script, so remove it and let gpiozero pick lgpio. Without the python3-pigpio package, the same setting fails earlier with ModuleNotFoundError: No module named 'pigpio'.


RPi.GPIO on the Raspberry Pi 5 (rpi-lgpio)

RPi.GPIO code runs on the Raspberry Pi 5, but not with the original library. Raspberry Pi OS ships rpi-lgpio ( python3-rpi-lgpio), a drop-in replacement with the same API built on lgpio. import RPi.GPIO loads it, and GPIO.VERSION reports 0.7.2. The original RPi.GPIO writes the Broadcom registers, so it doesn’t support the Pi 5.

Here is The Test Code For RPi.GPIO (rpigpio_demo.py)

Python Code example (RPi.GPIO API)

RPi.GPIO via rpi-lgpio on the Raspberry Pi 5: blink, read and add_event_detect callback with 5 of 5 edges
RPi.GPIO via rpi-lgpio on the Raspberry Pi 5: blink, read and add_event_detect callback with 5 of 5 edges

I also tested the rest of the RPi.GPIO API on rpi-lgpio in the Raspberry Pi GPIO tutorial: BCM and BOARD numbering, pull-ups, wait_for_edge, bouncetime, and software PWM all passed. The rpi-lgpio documentation lists the small differences.

The Original RPi.GPIO Error on the Raspberry Pi 5

To see what the original library does, I installed RPi.GPIO 0.7.1 from PyPI in a separate virtual environment (not in the system Python). It imports fine, then fails at the first GPIO.setup():

Original RPi.GPIO 0.7.1 on the Raspberry Pi 5: RuntimeError: Cannot determine SOC peripheral base address
Original RPi.GPIO 0.7.1 on the Raspberry Pi 5: RuntimeError: Cannot determine SOC peripheral base address

If you see RuntimeError: Cannot determine SOC peripheral base address, your script runs the original RPi.GPIO, usually from a pip install RPi.GPIO in a virtual environment or from the Debian package python3-rpi.gpio. Remove it and use rpi-lgpio ( sudo apt install python3-rpi-lgpio); a virtual environment created with --system-site-packages sees the system’s rpi-lgpio. This command tells you which one you have: python3 -c "import RPi.GPIO, sys; print('rpi-lgpio' if 'lgpio' in sys.modules else 'original')".

RPi.GPIO to gpiozero: The Four Common Patterns

For new code, gpiozero replaces the RPi.GPIO boilerplate with one object per part. The full mapping is in the gpiozero migration guide; these are the four patterns most scripts use:

RPi.GPIOgpiozero
GPIO.setup(17, GPIO.OUT), GPIO.output(17, 1)led = LED(17), led.on()
GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP), GPIO.input(27)btn = Button(27), btn.is_pressed
GPIO.add_event_detect(27, GPIO.FALLING, callback=f)btn.when_pressed = f
p = GPIO.PWM(17, 100), p.start(50)led = PWMLED(17), led.value = 0.5

lgpio on the Raspberry Pi 5 (Python and C)

lgpio is the library under gpiozero and rpi-lgpio on the Raspberry Pi 5, written by joan2937, the author of pigpio. It talks to /dev/gpiochip0 and gives you each pin directly: you open the chip, claim a pin as an output, input, or alert, and read or write it. It also has I2C, SPI, and serial helpers (lgpio documentation). The Python module ( python3-lgpio, 0.2.2) is pre-installed; for C, install the header with sudo apt install liblgpio-dev.

Here is The Test Code For lgpio in Python (lgpio_demo.py)

Python Code example (lgpio)

lgpio Python test on the Raspberry Pi 5: blink, GPIO24 read and 5 rising edges with lgpio.callback
lgpio Python test on the Raspberry Pi 5: blink, GPIO24 read and 5 rising edges with lgpio.callback

A pin must be claimed with gpio_claim_alert() to report edges. With gpio_claim_input() you can read it, but the callback never fires and no error tells you why.

Here is The Test Code For lgpio in C (lgpio_demo.c)

C Code example (lgpio)

lgpio C program on the Raspberry Pi 5: gcc build with -llgpio and the blink, read and edge callback output
lgpio C program on the Raspberry Pi 5: gcc build with -llgpio and the blink, read and edge callback output

Note: Closing the chip takes time in lgpio: lgGpiochipClose() ( gpiochip_close() in Python) blocked for 100ms on my Raspberry Pi 5, in both C and Python. A C program that opens, sets, and closes GPIO17 ran in 101ms, and in 1ms without the close call. It only matters for short programs started many times, such as a script called from cron.


libgpiod v2 on the Raspberry Pi 5 (Python, C++ and C)

libgpiod is the official library for the Linux GPIO character device, maintained with the kernel. Raspberry Pi OS Trixie ships version 2.2.1 with the command-line tools ( gpioset, gpioget, gpioinfo) and the Python bindings ( python3-libgpiod, import gpiod). For C and C++, install the headers with sudo apt install libgpiod-dev. The C++ examples and the full C++ walkthrough are in my Raspberry Pi GPIO tutorial.

Note: Raspberry Pi OS has libgpiod v2, and v1 code doesn’t run on it. Many Raspberry Pi 5 tutorials from 2023 use the v1 API ( chip.get_line(), LINE_REQ_DIR_OUT, gpiod_chip_open_by_name()). Use the v2 request API shown below.

Here is The Test Code For libgpiod in Python (gpiod_demo.py)

Python Code example (libgpiod v2 Python bindings)

libgpiod v2 Python bindings on the Raspberry Pi 5: blink, GPIO24 read and 5 rising edge events
libgpiod v2 Python bindings on the Raspberry Pi 5: blink, GPIO24 read and 5 rising edge events

libgpiod has no callback thread: the kernel queues each edge with a timestamp, and your program reads them with wait_edge_events() and read_edge_events(). That’s why the code drops the edge from step 2 before counting.

Here is The Test Code For libgpiod in C++ (libgpiod_demo.cpp)

C++ Code example (libgpiod v2)

libgpiod v2 C++ program on the Raspberry Pi 5: g++ build with pkg-config libgpiodcxx and the test output
libgpiod v2 C++ program on the Raspberry Pi 5: g++ build with pkg-config libgpiodcxx and the test output

The C API needs a few more objects (line settings, line config, request config), so here is the blink part only:

C Code example (libgpiod v2)

libgpiod v2 C program on the Raspberry Pi 5: gcc build with pkg-config libgpiod and the blink output
libgpiod v2 C program on the Raspberry Pi 5: gcc build with pkg-config libgpiod and the blink output

libgpiod v1 Python Code Error on the Raspberry Pi 5

This is the v1 Python code still found in popular 2023 Raspberry Pi 5 guides, run on Raspberry Pi OS Trixie. gpiod.Chip('gpiochip4') fails first because v2 expects a path; with /dev/gpiochip0 it fails at get_line:

libgpiod v1 Python code on the Raspberry Pi 5: FileNotFoundError for gpiochip4 and AttributeError: 'Chip' object has no attribute 'get_line'
libgpiod v1 Python code on the Raspberry Pi 5: FileNotFoundError for gpiochip4 and AttributeError: ‘Chip’ object has no attribute ‘get_line’

The C and C++ compile errors of v1 code are in the Raspberry Pi GPIO tutorial.


pigpio on the Raspberry Pi 5

pigpio doesn’t work on the Raspberry Pi 5. Its daemon, pigpiod, drives the Broadcom GPIO, PWM, and DMA blocks directly, and the Pi 5’s header is on RP1. The pigpio issue #589 (“pigpio will not run on a Pi 5”) has been open since November 2023, and the last pigpio release, v79, is from March 2021. On a Raspberry Pi 4 and older, pigpio still works, per its documentation.

Raspberry Pi OS Trixie doesn’t even package the daemon: sudo apt install pigpio finds nothing. Only the client side exists ( python3-pigpio and pigpio-tools), so an old pigpio script installs without complaint and then fails like this:

pigpio on the Raspberry Pi 5: pigpiod command not found, pigs socket connect failed, Can't connect to pigpio at localhost(8888)
pigpio on the Raspberry Pi 5: pigpiod command not found, pigs socket connect failed, Can’t connect to pigpio at localhost(8888)

What to use instead of pigpio on the Raspberry Pi 5:

  • lgpio for pigpio-style Python or C code: same author, similar calls ( gpio_write, callback, tx_pwm).
  • gpiozero with its default lgpio pin factory, instead of PiGPIOFactory.
  • The kernel PWM driver for jitter-free hardware PWM (servos), through the pwm or pwm-2chan overlay.

WiringPi on the Raspberry Pi 5

WiringPi works on the Raspberry Pi 5. The original author stopped it in 2019, but the project continues on GitHub: version 3.0 added the Raspberry Pi 5 in February 2024, and the latest release is 3.20 (September 2026). Per its README, only the GPIO clock (GCLK) function isn’t supported on the Pi 5. It isn’t in the Raspberry Pi OS repositories, so install the .deb from the releases page (96KB):

WiringPi 3.20 gpio -v on the Raspberry Pi 5: Type Pi 5, full user-level GPIO access via memory
WiringPi 3.20 gpio -v on the Raspberry Pi 5: Type Pi 5, full user-level GPIO access via memory

The gpio readall command prints the header with BCM, WiringPi, and physical numbers, and each pin’s mode and level. Here GPIO17 and GPIO23 show OUT and GPIO24 shows IN from the earlier tests:

WiringPi gpio readall on the Raspberry Pi 5: BCM, wPi and physical pin numbers with modes
WiringPi gpio readall on the Raspberry Pi 5: BCM, wPi and physical pin numbers with modes

Here is The Test Code For WiringPi (wiringpi_demo.c)

C Code example (WiringPi 3)

WiringPi C program on the Raspberry Pi 5: gcc build with -lwiringPi, blink, read and wiringPiISR callback with 5 of 5 edges
WiringPi C program on the Raspberry Pi 5: gcc build with -lwiringPi, blink, read and wiringPiISR callback with 5 of 5 edges

wiringPiSetupGpio() selects BCM numbers, so the code uses the same GPIO17, GPIO23, and GPIO24 as the other libraries. It ran as my normal user, with no sudo. WiringPi is C only today; the WiringPi-Python wrapper on PyPI (2.60.1, 2021) predates the Pi 5 support.


Raspberry Pi GPIO Library Speed Test

WiringPi is the fastest Raspberry Pi 5 GPIO library by far: it toggled GPIO17 at 20.0MHz, against 870kHz for libgpiod in C and 131kHz for gpiozero. Each library ran a tight loop that sets GPIO17 HIGH and LOW for 45 seconds, and I measured the frequency on my oscilloscope and with the program’s own counter (they agree within 1%).

Raspberry Pi 5 GPIO library speed test chart: WiringPi 20 MHz, libgpiod C 870 kHz, C++ 792 kHz, lgpio C 781 kHz, lgpio Python 458 kHz, gpiod Python 298 kHz, gpiozero 131 kHz, RPi.GPIO 129 kHz
Raspberry Pi 5 GPIO library speed test chart: WiringPi 20 MHz, libgpiod C 870 kHz, C++ 792 kHz, lgpio C 781 kHz, lgpio Python 458 kHz, gpiod Python 298 kHz, gpiozero 131 kHz, RPi.GPIO 129 kHz

LibraryLanguageToggle SpeedPeriod
RPi.GPIO (rpi-lgpio)Python129kHz7.8µs
gpiozeroPython131kHz7.6µs
libgpiod v2 bindingsPython298kHz3.35µs
lgpioPython458kHz2.18µs
lgpioC781kHz1.28µs
libgpiod v2C++792kHz1.26µs
libgpiod v2C870kHz1.15µs
WiringPi 3.20C20.0MHz50ns

The gpiozero, RPi.GPIO, lgpio Python, and libgpiod C++ numbers are the same runs as in my Raspberry Pi GPIO tutorial; I repeated them for this comparison and three of the four landed within 1.3% of those values. These are my oscilloscope captures of the four other libraries. Channel 1 (yellow) is GPIO17 (pin 11), and the orange arrow marks one period with its measured value:

libgpiod v2 Python bindings toggling GPIO17 on the Raspberry Pi 5 oscilloscope: 3.35 µs period, 298 kHz
libgpiod v2 Python bindings toggling GPIO17 on the Raspberry Pi 5 oscilloscope: 3.35 µs period, 298 kHz

lgpio C toggling GPIO17 on the Raspberry Pi 5 oscilloscope: 1.28 µs period, 781 kHz
lgpio C toggling GPIO17 on the Raspberry Pi 5 oscilloscope: 1.28 µs period, 781 kHz

libgpiod v2 C toggling GPIO17 on the Raspberry Pi 5 oscilloscope: 1.15 µs period, 870 kHz
libgpiod v2 C toggling GPIO17 on the Raspberry Pi 5 oscilloscope: 1.15 µs period, 870 kHz

At 20.0MHz, the WiringPi signal looks like a rounded wave between 0.56v and 2.52v. My probe is set to 1X, which limits its bandwidth to a few MHz; the frequency reading (20.00MHz, 50ns period) is exact and matches the program’s count of 19,995kHz:

WiringPi 3.20 toggling GPIO17 on the Raspberry Pi 5 oscilloscope: 50 ns period, 20 MHz
WiringPi 3.20 toggling GPIO17 on the Raspberry Pi 5 oscilloscope: 50 ns period, 20 MHz

Why WiringPi Is 23 Times Faster

The CPU time split shows where each loop spends its time. A kernel-path library makes one ioctl() system call per pin change; WiringPi writes the RP1 register from user space with no system call at all. I measured the user and kernel CPU seconds of each 5-second busy loop:

LibraryUser CPU (s)Kernel CPU (s)Time in Kernel
gpiozero (Python)3.781.3426%
RPi.GPIO (Python)3.791.2625%
gpiod (Python)3.561.5030%
lgpio (Python)2.462.5851%
lgpio (C)0.984.0280%
libgpiod (C++)0.974.0381%
libgpiod (C)0.614.3988%
WiringPi (C)5.000.000%

Every busy loop uses one full CPU core, whatever the library. The C programs on the kernel path spend 80% to 88% of that core inside the kernel, while WiringPi spends 0%. The price of WiringPi’s speed is that the kernel no longer arbitrates the pin: another program, or a driver that owns the pin, can be overwritten without any error. For most projects, 870kHz is far more than needed. Fast, exact timing belongs to the hardware peripherals (PWM, SPI) anyway, because Linux can pause any loop at any moment. When a project needs cycle-exact GPIO timing, a microcontroller such as the Raspberry Pi Pico does it better (see the Raspberry Pi Pico digital input and output tutorial).

Memory and Start-Up Time of Each Library

I also measured each library’s peak memory (resident set size, while toggling) and the time from launching the program until it set GPIO17 HIGH and exited:

LibraryPeak MemoryStart-Up Time
gpiozero (Python)19.9MB208ms
RPi.GPIO (Python)12.7MB38ms
gpiod (Python)13.1MB50ms
lgpio (Python)11.5MB29ms
lgpio (C)1.7MB102ms (100ms of it in the close call)
libgpiod (C++)3.4MB2.6ms
libgpiod (C)1.5MB1.6ms
WiringPi (C)1.8MB0.5ms

Python itself starts in about 15ms on the Pi 5, so most of gpiozero’s 208ms is its import time. On an 8GB Raspberry Pi 5, 20MB is not a problem; the start-up time only matters for scripts that are launched again and again.

Raspberry Pi 5 GPIO library start-up time and peak memory test output
Raspberry Pi 5 GPIO library start-up time and peak memory test output


Raspberry Pi GPIO Libraries: Versions, Licenses and Features

This table lists each library’s latest release, license, and features, checked on the projects’ official pages on November 28, 2026. The Raspberry Pi 5 column comes from my bench; the hardware PWM and I2C/SPI columns come from each project’s documentation.

LibraryLatest ReleaseLicenseNeeds Root or DaemonHardware PWMI2C / SPI
gpiozero2.0.1 (Feb 2024)BSD-3-ClauseNoNo (software PWM)SPI devices only
rpi-lgpio0.6 (May 2024)BSD-3-ClauseNoNo (software PWM)No
RPi.GPIO (original)0.7.1 (Feb 2022)MITNo (fails on Pi 5)No (software PWM)No
lgpio0.2.2 (2023)UnlicenseNoNo (software-timed)Yes
libgpiod2.3.2 (Nov 2026; Trixie ships 2.2.1)LGPL-2.1+NoNo (GPIO only)No (GPIO only)
pigpiov79 (Mar 2021)UnlicenseRoot daemonYes (Pi 4 and older)Yes (Pi 4 and older)
WiringPi3.20 (Sep 2026)LGPL-3.0No on the Pi 5Yes (per README)Yes

Raspberry Pi GPIO Library Errors and Fixes

RuntimeError: Cannot determine SOC peripheral base address

You’re running the original RPi.GPIO on a Raspberry Pi 5. Remove it ( pip uninstall RPi.GPIO in your virtual environment, or sudo apt install python3-rpi-lgpio to replace python3-rpi.gpio) and use rpi-lgpio, which keeps the same API.

Can’t connect to pigpio at localhost(8888)

pigpio’s daemon isn’t running, and on the Raspberry Pi 5 it can’t run: there is no pigpiod package in Raspberry Pi OS Trixie and no Pi 5 support upstream. Port the code to lgpio or gpiozero. In gpiozero, remove GPIOZERO_PIN_FACTORY=pigpio.

sudo: pigpiod: command not found

Same cause: Trixie only packages the pigpio client ( python3-pigpio, pigpio-tools), not the daemon.

OSError: unable to open /dev/gpiomem or /dev/mem

gpiozero’s NativeFactory was selected. It writes the Broadcom registers, which don’t drive the Pi 5 header. Use the default lgpio factory. Running it with sudo doesn’t fix it.

AttributeError: ‘Chip’ object has no attribute ‘get_line’

Your Python code uses the libgpiod v1 API. Rewrite it with gpiod.request_lines() as in the libgpiod section above.

Do I need sudo for any of these libraries?

No. gpiozero, rpi-lgpio, lgpio, libgpiod, and WiringPi 3 all ran as my normal user, which is in the gpio group. Only pigpio’s daemon needed root, and it doesn’t run on the Pi 5.


Raspberry Pi GPIO Library FAQ

Is RPi.GPIO deprecated?

The original RPi.GPIO hasn’t had a release since version 0.7.1 in February 2022 and doesn’t support the Raspberry Pi 5. Its API lives on through rpi-lgpio, which Raspberry Pi OS installs by default. New code should use gpiozero.

Is WiringPi deprecated?

No. The original author ended it in 2019, but the community project on GitHub released version 3.0 with Raspberry Pi 5 support in 2024 and version 3.20 in September 2026.

Does gpiozero support hardware PWM on the Raspberry Pi 5?

No. On the Pi 5, gpiozero’s PWMLED and PWMOutputDevice use lgpio’s software PWM. For hardware PWM, use the kernel PWM driver through the pwm overlay.

Can two libraries use the same GPIO pin?

Not with the kernel-path libraries: the kernel gives a line to one program at a time, and the second request fails with “Device or resource busy” or “GPIO busy”. WiringPi’s direct writes bypass that check, so avoid mixing it with other libraries on the same pins.


Download Raspberry Pi GPIO Library Examples

The download contains every test program from this tutorial (gpiozero, RPi.GPIO, lgpio, libgpiod, WiringPi, and pigpio), the speed-test loops in Python, C, and C++, the gpiozero pin factory test, and the CPU, memory, and start-up measurement script, with a README that lists each build command.

Download Raspberry Pi GPIO Library Examples (Python, C, C++)

Download all attachment files for this Article/Tutorial (project files, schematics, code, etc.) using the link below. Everything is tested and verified to work on real hardware, as you’ve seen in the demo videos & screenshots. Please consider supporting my work if it helped you.


Wrap Up

To conclude this tutorial, we’ve tested six Raspberry Pi GPIO libraries on the Raspberry Pi 5 with the same circuit and the same task. gpiozero, RPi.GPIO through rpi-lgpio, lgpio, libgpiod v2, and WiringPi 3 all work; the original RPi.GPIO and pigpio don’t, because they expect the Broadcom GPIO block that no longer drives the header. For new projects, I recommend gpiozero in Python and libgpiod in C and C++, and WiringPi when you need the last bit of speed in C.

To get started with the circuit and the basics of GPIO output and input in Python and C++, follow my Raspberry Pi GPIO tutorial. If your Raspberry Pi isn’t set up yet, start with the Raspberry Pi Setup Guide. The next tutorials in this Raspberry Pi series cover LED projects, push buttons with debouncing and interrupts, and PWM.

Share This Page With Your Network!
Join Our +25,000 Newsletter Subscribers!

Stay Updated With All New Content Releases. You Also Get Occasional FREE Coupon Codes For Courses & Other Stuff!

Photo of author
Author
Embedded systems engineer with several years of experience in embedded software and hardware design. I work as an embedded SW engineer in the Automotive & e-Mobility industry. However, I still do Hardware design and SW development for DSP, Control Systems, Robotics, AI/ML, and other fields I'm passionate about.
I love reading, writing, creating projects, and teaching. A reader by day and a writer by night, it's my lifestyle. I believe that the combination of brilliant minds, bold ideas, and a complete disregard for what is possible, can and will change the world! I will be there when it happens, will you?

Leave a Comment