[Python, at least for now.]

Is there a standard way to translate between the various naming formats for RPi GPIO pins? I.e., given a pin identifier in one of these forms: "BOARDn", "WPIn", "GPIO*", (int) n, and possibly "<function>", how can I derive the other forms?

I see that gpiozero has methods to translate everything to BCM pin numbers, and function names to physical pin information, but I haven't found anything in any of the libraries I've examined so far that go any farther than that, much less a universal nomenclature-to-nomenclature translation.

Why I want this is irrelevant; my question is whether such functionality is already available somewhere I have yet to look.



>>> from gpiozero.pins.data import *
>>> pii=pi_info()
>>> pii.physical_pin('GPIO4')
('J8', 7)
>>> pii.to_gpio('BOARD7')
>>> pii.to_gpio('GPIO4')
>>> pii.to_gpio('WPI7')
>>> pii.physical_pin('WPI7')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/gpiozero/pins/data.py", line 1268, in physical_pin
    raise PinNoPins('no pins can be used for %s' % function)
gpiozero.exc.PinNoPins: no pins can be used for WPI7

The BCM pin number is the common destination. There don't appear to be any methods to translate the BCM pin number to the board number, or the wiringPi number, for example. What I'm seeking is 'what the the X name for pin Y' where X and Y are the various formats.

  • I am not sure what are you asking, but my favourite "translation" means is "dictionary"
    – tlfong01
    Commented Jul 26, 2023 at 2:19
  • @tlfong01: Sure — if the appropriate dictionaries are defined in some library or other, that's exactly what I want. Finding them is my issue.
    – RoUS
    Commented Jul 26, 2023 at 2:39

1 Answer 1


There is only 1 naming convention understood by the SoC i.e. BCM.

WiringPi invented its own eclectic numbering (best avoided). There is code to translate BOARD numbers to BCM - which obviously depends on board. WiringPi & RPi.GPIO do this on every call - which strikes me as grossly inefficient (and makes the code confusing).

Most of those who program regularly only use BCM.

If you want to do your own conversion you might find the following helpful.

HEADER is a tuple to convert from BOARD to BCM.

HEADER = ('3.3v', '5v', 2, '5v', 3, 'GND', 4, 14, 'GND', 15, 17, 18, 27, 'GND', 22, 23, '3.3v', 24, 10, 'GND', 9, 25, 11, 8, 'GND', 7, 0, 1, 5, 'GND', 6, 12, 13, 'GND', 19, 16, 26, 20, 'GND', 21)

It would be trivial to make the reverse (at least for a 40 pin header).

  • As I said, why I want this is irrelevant to the question. Is your answer that no, there is no standard mapping provided by any of the popular libraries?
    – RoUS
    Commented Jul 26, 2023 at 3:43
  • none that I am aware of.
    – Milliways
    Commented Jul 26, 2023 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.