I never used wiringpi library before. I'm trying to understand how to read the output of gpio readall. What are the BCM and wPi columns? What does ALT0 mode mean? I searched online for output explanation but couldn't find anything. I found the following website, http://wiringpi.com/, but there is no full explanation of gpio readall Below is the output of my gpio readall

pi@cyb3:~ $ gpio readall
 +-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 | ALT0 | 1 |  3 || 4  |   |      | 5v      |     |     |
 |   3 |   9 |   SCL.1 | ALT0 | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 0 | IN   | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 1 | 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 | ALT0 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO | ALT0 | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK | ALT0 | 0 | 23 || 24 | 1 | OUT  | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 1 | OUT  | CE1     | 11  | 7   |
 |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
 |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
 |   6 |  22 | GPIO.22 |   IN | 1 | 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 3---+---+------+---------+-----+-----+
  • altX are the alternate functions of a pin. See here. BCM is the pin number when using GPIO (aka BCM) numbering scheme, and wPi is the pin number when using the wiringPi's own pin numbering scheme. So when using wiringPi, if you choose wiringPiSetup(), it'll default to using the wPi pin numbers, and wiringPiSetupGpio() will result in using the GPIO/BCM numbers. – stevieb May 9 '17 at 19:05
  • 1
    @stevieb Why not make that an answer? – joan May 9 '17 at 19:44
  • @joan Done!... :) – stevieb May 9 '17 at 20:08
  • man gpio SHOULD install the documentation, however it is missing. See raspberrypi.stackexchange.com/a/51347/8697 for detail of how to install it. – Milliways May 10 '17 at 1:00
up vote 3 down vote accepted

The ALTx signifies the alternate functions of a pin. See this for a better understanding.

BCM is the pin number when using GPIO (aka BCM) numbering scheme, and wPi is the pin number when using the wiringPi's own pin numbering scheme. So when using wiringPi, if you choose wiringPiSetup(), it'll default to using the wPi pin numbers, and wiringPiSetupGpio() will result in using the GPIO/BCM numbers.

There is a great write up on this at https://iotbreaks.com/understand-gpio-readall-bash-shell-command-output-on-raspberry-pi/

In keeping with the "Good answers" guidelines, I'll plagiarize the relevant part:

“Physical” column

This is the pin number on the connector. it is simply the physical number which is marked as the following picture. We can easily count its 40 pins without caring the functions.

RaspberryPi GPIO PINs

“V” column

This indicates the voltage level of the pins. As you may notice, the “0/1” value is applicable for GPIO pins only, and leave blank for the rest. V=0 indicates the voltage level on the pin is LOW, the exact voltage value is 0V. In contrast, V=1 indicates the voltage level on the pin is HIGH, the exact voltage value is 3.3V.

“Mode” column

The “Mode” shows how the pin is being used. Here is the list of valid modes able to set for GPIO: in/out/pwm/clock/up/down/tri. However, you also see the “ALT[#]” listed in the Mode column. This ALT[#] indicates the GPIO pin is being used as alternative function – a specific function, not as general purpose function.

  • in: the GPIO pin is used as input without software-register-pull-up or software-register-pull-down. In this mode, if the pin is not connected to any reference point, the input state will be unknown (it is floated).
  • out: the GPIO pin is used as output, and without software-register-pull-up or software-register-pull-down. In this mode, if the pin is not connected to any reference point, the input state will be unknown (it is floated).
  • pwm: the GPIO pin is used as hardware Pulse-Width-Modulation mode which is square waveform generation. This mode is usually used to control DC motor speed or LED dimming. Keep in mind that only BCM 18 (or GPIO.1) supports PWM output mode.
  • clock: the GPIO pin is used as clock generater. The frequency of clock is driven from main crystal frequency of Raspberry Pi. Note that only BCM 4 (or GPIO.7) supports CLOCK output mode.
  • up: The GPIO pin is used as input with software-register-pull-up. In this mode, if the pin is not connected to any reference point, the input state will be HIGH (or 1).
  • down: The GPIO pin is used as input with software-register-pull-down. In this mode, if the pin is not connected to any reference point, the input state will be LOW (or 0).
  • tri: The GPIO pin is used as input without software-register-pull-down or up. In this mode, if the pin is not connected to any reference point, the input state will be LOW or HIGH.
  • ALT[#]: The GPIO pin is used as a special function. You can check the list of those special functions at this link.

“Name” column

This show the names of pins. The name hints us the functions of pins. It is also used as BOARD number when we use GPIO.BOARD mode. This uses P1 header pin numbering convention.

“wPi” column

This is simply a “GPIO”-removed text of “Name” column.

“BCM” column

This is the number of AMR peripherals. we use this number with “gpio” command. For example, “gpio mode 22 in” means that we use BCM 3 pin(Physical-15/Name-GPIO.73) as an input.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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