TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: ALL
from: DENNIS LEE BIEBER
date: 2019-11-18 13:00:00
subject: Re: Accessing GPIO pins u

On Mon, 18 Nov 2019 08:22:41 +0100, "R.Wieser" 
declaimed the following:

>Dennis,
>
>> There are NO internal tables...
>
>Please re-read my definition of 'internal'.  That you have your own (which
>you have not mentioned yet) should not be the basis of an argument.
>

 I'll plead "overlapping posts"


>True.  Sow, how about that GPIO library exposing what it uses ?   So that
>I/we can convert from one of its pinnaming schemes to its other one(s) ?
>

 {blast -- Looks like I need to reimage my 3B+ -- the file manager is
crashing on start-up}

 NOTE: the conversion is from user-name to physical (SoC) number, no
reverse look-up.

>>> import gpiozero
>>> myPi = gpiozero.pins.data.pi_info()
>>> myPi.to_gpio("GPIO17")
17
>>> myPi.to_gpio(11)
11
>>> myPi.to_gpio("BOARD11")
17
>>> myPi.to_gpio("WPI11")
7
>>> myPi.to_gpio("J8:11")
17
>>> myPi.to_gpio("BCM17")
17
>>>
>>> myPi.physical_pins("5V")
{('J8', 2), ('J8', 4)}
>>> myPi.physical_pins("3V3")
{('J8', 1), ('J8', 17)}
>>> myPi.physical_pins("1V8")
set()
>>> myPi.physical_pins("GND")
{('J8', 30), ('J8', 9), ('J8', 34), ('J8', 20), ('J8', 14), ('J8', 39),
('J8', 25), ('J8', 6)}
>>> myPi.physical_pins("NC")
set()
>>> myPi.physical_pins("GPIO17")
{('J8', 11)}
>>>
>>> myPi.physical_pin("5V")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3/dist-packages/gpiozero/pins/data.py", line 1158,
in physical_pin
    raise PinMultiplePins('multiple pins can be used for %s' % function)
gpiozero.exc.PinMultiplePins: multiple pins can be used for 5V
>>> myPi.physical_pin("3V3")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3/dist-packages/gpiozero/pins/data.py", line 1158,
in physical_pin
    raise PinMultiplePins('multiple pins can be used for %s' % function)
gpiozero.exc.PinMultiplePins: multiple pins can be used for 3V3
>>> myPi.physical_pin("GPIO17")
('J8', 11)
>>>
>>> myPi.model
'3B+'
>>> myPi.storage
'MicroSD'
>>> myPi.usb
4
>>> myPi.soc
'BCM2837'
>>> myPi.manufacturer
'Sony'
>>> myPi.bluetooth
True
>>> myPi.headers["J8"].pins[17]
PinInfo(number=17, function='3V3', pull_up=False, row=9, col=1)
>>> myPi.headers["J8"].pins[11]
PinInfo(number=11, function='GPIO17', pull_up=False, row=6, col=1)
>>>

 Is there any other information you want from it?


Heh! This is what I get for reading the source and not the documentation...

 myPi = gpiozero.pins.data.pi_info()

can be simplified to

 myPi = gpiozero.pi_info()

https://gpiozero.readthedocs.io/en/stable/api_info.html

>>> myPi.pprint()
,--------------------------------.
| oooooooooooooooooooo J8     +====
| 1ooooooooooooooooooo  PoE   | USB
|  Wi                    oo   +====
|  Fi  Pi Model 3B+ V1.3 oo      |
|        ,----.               +====
| |D|    |SoC |               | USB
| |S|    |    |               +====
| |I|    `----'                  |
|                   |C|     +======
|                   |S|     |   Net
| pwr        |HDMI| |I||A|  +======
`-| |--------|    |----|V|-------'

Revision           : a020d3
SoC                : BCM2837
RAM                : 1024Mb
Storage            : MicroSD
USB ports          : 4 (excluding power)
Ethernet ports     : 1
Wi-fi              : True
Bluetooth          : True
Camera ports (CSI) : 1
Display ports (DSI): 1

J8:
   3V3  (1) (2)  5V
 GPIO2  (3) (4)  5V
 GPIO3  (5) (6)  GND
 GPIO4  (7) (8)  GPIO14
   GND  (9) (10) GPIO15
GPIO17 (11) (12) GPIO18
GPIO27 (13) (14) GND
GPIO22 (15) (16) GPIO23
   3V3 (17) (18) GPIO24
GPIO10 (19) (20) GND
 GPIO9 (21) (22) GPIO25
GPIO11 (23) (24) GPIO8
   GND (25) (26) GPIO7
 GPIO0 (27) (28) GPIO1
 GPIO5 (29) (30) GND
 GPIO6 (31) (32) GPIO12
GPIO13 (33) (34) GND
GPIO19 (35) (36) GPIO16
GPIO26 (37) (38) GPIO20
   GND (39) (40) GPIO21
>>>

{That can also be produced by the gpiozero command line tool: pinout


--
 Wulfraed                 Dennis Lee Bieber         AF6VN
 wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.