How to access a Raspberry Pi Zero’s GPIO pins from Fedora

When hacking with a Raspberry Pi Zero (or similar device), many makers use the General Purpose Input / Output (GPIO) pins. These pins are used to attach and control a wide range of devices such as LEDs or sensors to measure temperature, light, or humidity. However, if you prefer to code on your desktop or laptop this may be an issue since most of these devices don’t have accessible GPIO pins. This is where GPIO expander software can help.

The main goal of GPIO expander software is to use the Raspberry Pi Zero as an USB device connected to a personal computer, where the GPIO pins of the Raspberry Pi Zero will be made available to the host computer.

This article walks through the steps for setting up and using the GPIO expander software with a Raspberry Pi Zero on Fedora.

raspberry pi zero connected to a fedora laptop

Connect the Raspberry Pi Zero

Connect the micro USB port (not the one labelled PWR) of the Raspberry Pi Zero to your computer. Once connected, run the lsusb command, and a new USB device like this should appear:

Bus 004 Device 005: ID 0a5c:2763 Broadcom Corp.

Building GPIOexpander

Next, we are going to build GPIOexpander from source. Install the following build dependencies using dnf:

sudo dnf install git gcc bc cmake flex unzip bison gcc-c++ wget patch python2 perl-ExtUtils-MakeMaker perl-Thread-Queue libusb-devel

Then, create a directory for the sources and check them out using git

$ mkdir ~/pi_hacking 
$ cd ~/pi_hacking
$ git clone --depth 1 
$ git clone --depth=1

Next, build GPIOexpander:

$ cd ~/pi_hacking/gpioexpander
$ ./

Finally, build usbboot.

$ cd ~/pi_hacking/usbboot
$ make

usbboot is responsible to boot the Raspberry from the host device (your PC) via USB (like booting a computer via an external mass storage) loading a very bare minimal system, while gpioexpander emulates an USB Ethernet dongle and runs the pigpiod daemon on the Raspberry Pi Zero.

Finalize the setup

Now, change back to the usbboot git checkout, and issue this command:

$ cd ~/pi_hacking/usbboot
$ sudo ./rpiboot -d ../gpioexpander/output

You should see some messages looking like a boot process. Once finished, look at the network interfaces on your PC, using the “ifconfig” command.  A new network interface named similar to “enp0s20f0u1i2” with an IPv6 address assigned to it. Try pinging the Rasperry Pi Zero, where enp0s20f0u1i2 is the name of the interface created on your computer

$ ping6 fe80::1%enp0s20f0u1i2

Next, install the gpiozero Python package, and export the following bash variables:

Note: replace enp0s20f0u1i2 with the name of the interface created on your computer:

$ pip3 install gpiozero --user
$ export GPIOZERO_PIN_FACTORY=pigpio
$ export PIGPIO_ADDR=fe80::1%enp0s20f0u1i2

Test it out

Connect a LED to pin 20 (GPIO 25), start python3, and issue the following python code to make the LED blink:

$ python3
>>> from gpiozero import LED
>>> led = LED(25)
>>> led.blink()

The LED should blink. Awesome!

Now you can use the power of your Fedora workstation to use the Raspberry Pi Zero GPIO pins. Please note that you are limited to the GPIO Zero Python library and you can not use, for instance, the RPi.GPIO one. However the aim of this tool is to provide a simple to use system, useful for teaching sessions and experiments without the need of a network or a monitor, a power supply, a keyboard and a mouse in order to use the GPIO pins directly from a laptop or a workstation.

Fedora Project community


  1. Jason K

    This was a great article. Combined with the documentation for gpiozero, I was able to have a Pi Zero control a motor based on input from a temperature sensor. Might be nice to folow up with either articles on how to use other hardware with fedora – like the ACR122U for NFC cards , or perhaps integration with other system features (like integration via a PAM module or using notify-send and zenity to handle input and output).

    • Alessio

      In fact. Using GPIO expander you are not installing Fedora on the RPi Zero. You are using the RPi zero as an USB device, like a GPIO USB device accessible from your Fedora workstation.

    • Jaša B.

      David, that wiki page says Fedora itself does not RUN on ARMv6 CPUs, such as the Zero uses. You can still communicate with a Zero using a computer that Fedora does run on, suck as the laptop from the photograph in the article.

  2. At least on RPi3, for GPIO control from eg, scripts, you need to install libgpiod-utils from Fedora now because the old GPIO sysfs interface is deprecated and disabled in Fedora kernels. There’s no need to build anything.

    This comes with C utilities like gpioset that replace the old sysfs stuff and give you more features, like autotimed gpio strobing.

  3. Rene Reichenbach

    Thx for this nice tutorial! Will help some teachers and pupil to get started.

    Small issue with the text :

    $ git clone –depth 1
    $ git clone –depth=1

    and may decide for “–depth=1” or “–depth 1”

    • Alessio

      “–depth 1” is the syntax you can find in the git manual. Btw “–depth=1” it works as well.

Comments are Closed

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. Fedora Magazine aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. The Fedora logo is a trademark of Red Hat, Inc. Terms and Conditions

%d bloggers like this: