23. API - Pi Information

The GPIO Zero library also contains a database of information about the various revisions of the Raspberry Pi computer. This is used internally to raise warnings when non-physical pins are used, or to raise exceptions when pull-downs are requested on pins with physical pull-up resistors attached. The following functions and classes can be used to query this database:

23.1. pi_info


Deprecated function for retrieving information about a revision of the Raspberry Pi. If you wish to retrieve information about the board that your script is running on, please query the Factory.board_info property like so:

>>> from gpiozero import Device
>>> Device.ensure_pin_factory()
>>> Device.pin_factory.board_info
PiBoardInfo(revision='a02082', model='3B', pcb_revision='1.2',
released='2016Q1', soc='BCM2837', manufacturer='Sony', memory=1024,
storage='MicroSD', usb=4, usb3=0, ethernet=1, eth_speed=100, wifi=True,
bluetooth=True, csi=1, dsi=1, headers=..., board=...)

To obtain information for a specific Raspberry Pi board revision, use the PiBoardInfo.from_revision() constructor.


revision (str) – The revision of the Pi to return information about. If this is omitted or None (the default), then the library will attempt to determine the model of Pi it is running on and return information about that.

23.2. PiBoardInfo

class gpiozero.PiBoardInfo(revision, model, pcb_revision, released, soc, manufacturer, memory, storage, usb, usb3, ethernet, eth_speed, wifi, bluetooth, csi, dsi, headers, board)[source]

23.3. HeaderInfo

class gpiozero.HeaderInfo(name, rows, columns, pins)[source]

This class is a namedtuple() derivative used to represent information about a pin header on a board. The object can be used in a format string with various custom specifications:

from gpiozero.pins.native import NativeFactory

factory = NativeFactory()
j8 = factory.board_info.headers['J8']
p1 = factory.board_info.headers['P1']

“color” and “mono” can be prefixed to format specifications to force the use of ANSI color codes. If neither is specified, ANSI codes will only be used if stdout is detected to be a tty. “rev” can be added to output the row or column in reverse order:

# force use of ANSI codes
j8 = factory.board_info.headers['J8']
print(f'{j8:color row2}')
# force plain ASCII
print(f'{j8:mono row2}')
# output in reverse order
print(f'{j8:color rev row1}')

The following attributes are defined:


Pretty-print a diagram of the header pins.

If color is None (the default, the diagram will include ANSI color codes if stdout is a color-capable terminal). Otherwise color can be set to True or False to force color or monochrome output.


The name of the header, typically as it appears silk-screened on the board (e.g. “P1” or “J8”).


The number of rows on the header.


The number of columns on the header.


A dictionary mapping physical pin numbers to PinInfo tuples.

23.4. PinInfo

class gpiozero.PinInfo(number, name, names, pull, row, col, interfaces)[source]

This class is a namedtuple() derivative used to represent information about a pin present on a GPIO header. The following attributes are defined:


An integer containing the physical pin number on the header (starting from 1 in accordance with convention).


A string describing the function of the pin. Some common examples include “GND” (for pins connecting to ground), “3V3” (for pins which output 3.3 volts), “GPIO9” (for GPIO9 in the board’s numbering scheme), etc.


A set of all the names that can be used to identify this pin with BoardInfo.find_pin(). The name attribute is the “typical” name for this pin, and will be one of the values in this set.

When “gpio” is in interfaces, these names can be used with Factory.pin() to construct a Pin instance representing this pin.


A string indicating the fixed pull of the pin, if any. This is a blank string if the pin has no fixed pull, but may be “up” in the case of pins typically used for I2C such as GPIO2 and GPIO3 on a Raspberry Pi.


An integer indicating on which row the pin is physically located in the header (1-based)


An integer indicating in which column the pin is physically located in the header (1-based)


A dict mapping interfaces that this pin can be a part of to the description of that pin in that interface (e.g. “i2c” might map to “I2C0 SDA”). Typical keys are “gpio”, “spi”, “i2c”, “uart”, “pwm”, “smi”, and “dpi”.


Deprecated variant of pull.


Deprecated alias of name.