๐ŸŒ
GitHub
github.com โ€บ wiringpi โ€บ wiringpi
GitHub - WiringPi/WiringPi: The arguably fastest GPIO Library for the Raspberry Pi ยท GitHub
Welcome to the WiringPi Library, the highly performant GPIO access library for Raspberry Pi boards.
Starred by 3.3K users
Forked by 1.3K users
Languages ย  C 90.0% | Makefile 3.4% | Shell 2.9% | C++ 2.0% | Roff 1.1% | TeX 0.6%
๐ŸŒ
Raspberry Pi Forums
forums.raspberrypi.com โ€บ board index โ€บ programming โ€บ c/c++
WiringPi replacement? - Raspberry Pi Forums
April 19, 2024 - 'Gordon's wiringPi' which has been deprecated Note that this is not the current wiringPi/wiringPi repository which has taken over from Gordons.
Discussions

'WiringPi' is back from the dead
TLDR: GPIO access library written in C for Raspberry Pi. More on reddit.com
๐ŸŒ r/raspberry_pi
16
75
February 29, 2024
Wiring pi is defunct.
I used to love using the Wiring Pi library in C for programing the IO of the Raspberry pi. I haven't used a PI for a project in a while, and I guess in that time developer of WiringPi has stopped supporting the library. I tried using version 2.52 on a raspberry pi 4, but it says something like More on community.element14.com
๐ŸŒ community.element14.com
1
0
December 21, 2023
wiringpi is missing from bullseye. how do i install it? - Raspberry Pi Stack Exchange
I get the following when trying to install wiring pi on a fresh bullseye image. Anyone have any way to get it installed? $ sudo apt-get install wiringpi Reading package lists... Done Building More on raspberrypi.stackexchange.com
๐ŸŒ raspberrypi.stackexchange.com
raspberry pi - How to enable wiringpi GPIO control inside a Docker container - Stack Overflow
I've used the answer to this question to enable control of my Raspberry Pi GPIO pins from within a Docker container, which runs Alpine. $ docker run --device /dev/gpiomem whatever This works with ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Pinout
pinout.xyz โ€บ pinout โ€บ wiringpi
WiringPi at Raspberry Pi GPIO Pinout
WiringPi is an attempt to bring Arduino-wiring-like simplicity to the Raspberry Pi.
๐ŸŒ
SunFounder
docs.sunfounder.com โ€บ projects โ€บ superkit-v3-pi โ€บ en โ€บ latest โ€บ wiringpi.html
WiringPi โ€” SunFounder Super_Kit_V3.0_for_Raspberry_Pi documentation
wiringPi is a C language GPIO library applied to the Raspberry Pi. It complies with GUN Lv3. The functions in wiringPi are similar to those in the wiring system of Arduino.
Find elsewhere
๐ŸŒ
Wiringpi
wiringpi.com
WiringPi
This is wiringpi.com.
๐ŸŒ
SparkFun Learn
learn.sparkfun.com โ€บ tutorials โ€บ raspberry-gpio โ€บ c-wiringpi-setup
C (WiringPi) Setup - Raspberry gPIo - SparkFun Learn
Python is a great GPIO-driving option, especially if you're used to it. But if you're a rickety old programmer, unfamiliar with the whitespace-driven scripting language, and would rather live within the happy confines of C, then let me introduce the WiringPi library.
๐ŸŒ
SunFounder
docs.sunfounder.com โ€บ projects โ€บ raphael-kit โ€บ en โ€บ latest โ€บ c โ€บ check_the_wiringpi_c.html
Install and Check the WiringPi โ€” SunFounder Ulimate Raphael Kit for Raspberry Pi documentation
wiringPi is a C language GPIO library applied to the Raspberry Pi. It complies with GUN Lv3. The functions in wiringPi are similar to those in the wiring system of Arduino.
๐ŸŒ
GitHub
github.com โ€บ hardkernel โ€บ wiringPi
GitHub - hardkernel/wiringPi
This version may lag the official Drogon release. Pull requests may not be accepted to Github.... Please see http://wiringpi.com/ for the official documentation, etc. and the best way to submit bug reports, etc. is by sending an email to projects@drogon.net Thanks!
Starred by 66 users
Forked by 63 users
Languages ย  C 94.9% | TeX 3.1% | Roff 1.2% | C 94.9% | TeX 3.1% | Roff 1.2%
๐ŸŒ
GitHub
github.com โ€บ WiringPi โ€บ WiringPi-Python
GitHub - WiringPi/WiringPi-Python: Unofficial Python-wrapped version of Gordon Henderson's WiringPi version 2.
WiringPi: An implementation of most of the Arduino Wiring functions for the Raspberry Pi.
Starred by 543 users
Forked by 238 users
Languages ย  SWIG 73.1% | Python 26.9% | SWIG 73.1% | Python 26.9%
๐ŸŒ
SparkFun Learn
learn.sparkfun.com โ€บ tutorials โ€บ raspberry-gpio โ€บ c-wiringpi-api
C (WiringPi) API - Raspberry gPIo
language:c wiringPiSetup(); // Initializes wiringPi using wiringPi's simlified number system.
๐ŸŒ
Gordons Projects
projects.drogon.net โ€บ home โ€บ raspberry pi โ€บ wiringpi โ€บ functions (api)
Raspberry Pi | WiringPi | Functions | Gordons Projects
November 22, 2015 - This initialises the wiringPi system and assumes that the calling program is going to be using the wiringPi pin numbering scheme. This is a simplified numbering scheme which provides a mapping from virtual pin numbers 0 through 16 to the real underlying Broadcom GPIO pin numbers.
๐ŸŒ
PlatformIO
docs.platformio.org โ€บ en โ€บ latest โ€บ frameworks โ€บ wiringpi.html
WiringPi โ€” PlatformIO latest documentation
WiringPi is a PIN based GPIO access library written in C for the BCM2835, BCM2836 and BCM2837 SoC devices used in all Raspberry Pi
๐ŸŒ
Electronic Wings
electronicwings.com โ€บ raspberry-pi โ€บ how-to-use-wiringpi-library-on-raspberry-pi
How to use WiringPi Library on Raspberry Pi | Raspberry Pi
WiringPi is a library written in C used to access GPIO pins on Raspberry for BCM2835 (Broadcom Processor) SoC (System on Chip). There are various libraries are available to access GPIO in C like bcm 2835, sysfs, pigpio, etc.
Top answer
1 of 2
3

Warning: Thar be hacks ahead.

The fundamental problem, as I noted in my comment, is that your containerized wiringPi is simply too old. Older Pi harwdare (like the Pi 2) used the BCM2708/BCM2709 processors, but newer hardware uses the BCM2835. WiringPi needs to know what processor is in use in order to correctly locate the GPIO control registers.

It's possible that there isn't a substantial difference between the older and newer processors as far as GPIO goes. If -- and only if -- this is the case, you can "trick" your containerized wiringPi into working.

  1. Create a version a /proc/cpuinfo with the desired processor name:

    sed s/BCM2835/BCM2709/ < /proc/cpuinfo > /proc/cpuinfo
    
  2. Bind mount that onto /proc/cpuinfo inside the container. You'll also need to provide /dev/mem, and you'll need to run with --privileged:

    docker run -it --rm --privileged --device /dev/mem -v /tmp/cpuinfo:/proc/cpuinfo alpine sh
    

This gives us:

/ # gpio -v
gpio version: 2.26
Copyright (c) 2012-2015 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

Raspberry Pi Details:
  Type: Model 2, Revision: 1.1, Memory: 1024MB, Maker: Sony [OV]
/ # gpio readall
 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 |   IN | 0 |  3 || 4  |   |      | 5V      |     |     |
 |   3 |   9 |   SCL.1 |   IN | 0 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 0 |  7 || 8  | 0 | IN   | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 0 | IN   | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 0 | IN   | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 0 | IN   | CE1     | 11  | 7   |
 |   0 |  30 |   SDA.0 |   IN | 0 | 27 || 28 | 0 | IN   | SCL.0   | 31  | 1   |
 |   5 |  21 | GPIO.21 |   IN | 0 | 29 || 30 |   |      | 0v      |     |     |
 |   6 |  22 | GPIO.22 |   IN | 0 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |
 |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |
 |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
 |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+

You would want to experiment to see if this actually works as intended.

Or just run a Raspbian image instead of an Arch image.

2 of 2
2

Thanks to larsks for pointing out the difference in version numbers.

Version 2.46 of wiringPi is available for Alpine, but I'd failed to notice it's only in the edge branch of the community repository

To use this version I had to modify the file /etc/apk/repositories, replacing the existing community entry with the edge version.

Since I'm using Docker, I had to do this as part of the image build process, so I added the following to my Dockerfile:

RUN sed -i "s/v[0-9.]*\/community/edge\/community/" /etc/apk/repositories \
    && apk update && apk add wiringpi