picandies
Posts: 240
Joined: Wed Nov 26, 2014 5:13 pm

Command to check GPIO'S?

Thu Dec 05, 2019 7:50 pm

What command(s) can be used right after booting up is completed to check the states /modes of all the GPIO's?
I believe it is a linux command, rather than python command (though either is fine). This is an RPI3B

Also, I'm investigating GPIO 14...I believe GPIO 1-8 are set as inputs with hi-pullups & the rest areset as inputs with low-pullups.
However, GPIO 14 seems to be set as an output (even if I load with 5K), so this does NOT match what I've read.
Is there an official (up to date) list?

Of course with the proper commands, I can always verify myself.


User avatar
joan
Posts: 14765
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Command to check GPIO'S?

Thu Dec 05, 2019 8:34 pm

GPIO14 has always been serial TXD which is high by default. It sounds like you have enabled the console or serial link. You can use raspi-config to disable this behaviour.

picandies
Posts: 240
Joined: Wed Nov 26, 2014 5:13 pm

Re: Command to check GPIO'S?

Thu Dec 05, 2019 10:11 pm

Thanks for the wiring pi tip....however:

I'm not using wiring pi (but perhaps could).
I need to see whether each pin is in/out, or something else and hi/lo (if output)
I want to look at ALL of the pins, not one...right after boot is finished & I can start typing

Isn't there a command to type in to list this info for them? Maybe my imagination?

DirkS
Posts: 10220
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Command to check GPIO'S?

Thu Dec 05, 2019 10:45 pm

picandies wrote:
Thu Dec 05, 2019 10:11 pm
Thanks for the wiring pi tip....however:

I'm not using wiring pi (but perhaps could).
IIRC it's installed by default on the RPF images.

There's also the RPF GPIO utility:

Code: Select all

raspi-gpio get

RonR
Posts: 849
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Command to check GPIO'S?

Thu Dec 05, 2019 11:06 pm

DirkS wrote:
Thu Dec 05, 2019 10:45 pm
IIRC it's installed by default on the RPF images.

There's also the RPF GPIO utility

Not on Raspbian Buster Lite.

DirkS
Posts: 10220
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Command to check GPIO'S?

Thu Dec 05, 2019 11:09 pm

RonR wrote:
Thu Dec 05, 2019 11:06 pm
DirkS wrote:
Thu Dec 05, 2019 10:45 pm
IIRC it's installed by default on the RPF images.

There's also the RPF GPIO utility

Not on Raspbian Buster Lite.

Code: Select all

sudo apt update
sudo apt raspi-gpio

RonR
Posts: 849
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Command to check GPIO'S?

Thu Dec 05, 2019 11:15 pm

DirkS wrote:
Thu Dec 05, 2019 11:09 pm

Code: Select all

sudo apt update
sudo apt raspi-gpio

I know how to install them, but they're not installed by default as you speculated.

picandies
Posts: 240
Joined: Wed Nov 26, 2014 5:13 pm

Re: Command to check GPIO'S?

Fri Dec 06, 2019 6:16 am

Hey guys , thanks for the tip.
By the way, I found a command you may not have heard of (there seem to be many undocumented or hard to find):
gpio readall


The will also show a very informative listing of all the I/Os!

User avatar
rpdom
Posts: 16398
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Command to check GPIO'S?

Fri Dec 06, 2019 6:19 am

picandies wrote:
Fri Dec 06, 2019 6:16 am
Hey guys , thanks for the tip.
By the way, I found a command you may not have heard of (there seem to be many undocumented or hard to find):
gpio readall


The will also show a very informative listing of all the I/Os!
That is the gpio command from WiringPi.

User avatar
Milliways
Posts: 519
Joined: Fri Apr 25, 2014 12:18 am
Location: Sydney, Australia

Re: Command to check GPIO'S?

Fri Dec 06, 2019 6:29 am

picandies wrote:
Fri Dec 06, 2019 6:16 am
Hey guys , thanks for the tip.
By the way, I found a command you may not have heard of (there seem to be many undocumented or hard to find):
gpio readall


The will also show a very informative listing of all the I/Os!
Now that wiringpi is deprecated (and requires a download from the author's site to work on the Pi4) the future of this command is unknown.

I wrote a replacement (which uses pigpiod) - which has the advantage of displaying the ACTUAL programmed GPIO function if changed.
https://www.raspberrypi.org/forums/view ... 6&t=254071

User avatar
rpdom
Posts: 16398
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Command to check GPIO'S?

Fri Dec 06, 2019 7:01 am

The "raspi-gpio get" command will list the status of all GPIOs (not just those available on the connector). You can limit it with "raspi-gpio get 2-27" to just list the ones available for general use. This won't show them in a pretty order with pin numbers, but it is the official tool for work with GPIOs.

User avatar
Milliways
Posts: 519
Joined: Fri Apr 25, 2014 12:18 am
Location: Sydney, Australia

Re: Command to check GPIO'S?

Sun Dec 08, 2019 1:53 am

rpdom wrote:
Fri Dec 06, 2019 7:01 am
The "raspi-gpio get" command will list the status of all GPIOs (not just those available on the connector). You can limit it with "raspi-gpio get 2-27" to just list the ones available for general use. This won't show them in a pretty order with pin numbers, but it is the official tool for work with GPIOs.
I just looked at this (which I was unaware of) and noted that it outputs lines like

Code: Select all

GPIO 4: level=1 fsel=0 func=INPUT pull=UP
My reading of the peripherals documentation (which is rather confusing) states that it is not possible to read state of pull-ups and the user must remember these. I have seen similar comments in WiringPi documentation.

I am intrigued how this is determined.

I will have to run a few tests to see what it reports.

A quick test with echo "pud 4 d" >/dev/pigpio shows that it does indeed work as this now shows

Code: Select all

GPIO 4: level=0 fsel=0 func=INPUT pull=DOWN

User avatar
rpdom
Posts: 16398
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Command to check GPIO'S?

Sun Dec 08, 2019 4:26 am

Milliways wrote:
Sun Dec 08, 2019 1:53 am
My reading of the peripherals documentation (which is rather confusing) states that it is not possible to read state of pull-ups
It is possible on the Pi4. The GPIO configuration is different. The forthcoming documentation will show the changes.

Return to “General discussion”