Skip to the content
2 layers91.4 × 67.9 mmRpi wiringpi unit test platform board-3, the printed circuit board in 3D

Rpi wiringpi unit test platform board-3

stevieb9/rpi-wiringpi10

Perl interface to Raspberry Pi's board, GPIO and various sensors and ICs

Size
91.4 × 67.9 mm
Copper layers
2
Thickness
1.6 mm
Parts
28
Nets
48
Pads
124
Tracks, vias
294, 37
Pours
2
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
10 Aug 2016
Updated
26 Sep 2026

Overview

Rpi wiringpi unit test platform board-3 is an open-source printed circuit board by stevieb9, from the stevieb9/rpi-wiringpi repository on GitHub. It is a 2-layer board of 91.4 × 67.9 mm with 28 parts on 48 nets, routed with 294 tracks and 37 vias.

Its parts include 8 connectors, 6 resistors, 4 diodes, 3 capacitors and 2 ICs. It belongs with the interfaces and adapters boards of this library.

README

README.md

NAME

RPi::WiringPi - Perl interface to Raspberry Pi's board, GPIO, LCDs and other various items

Table of Contents

SYNOPSIS

Please see the FAQ for full usage details.

text
   use RPi::WiringPi;
   use RPi::Const qw(:all);

   my $pi = RPi::WiringPi->new;

   # For the below handful of system methods, see RPi::SysInfo

   my $mem_percent = $pi->mem_percent;
   my $cpu_percent = $pi->cpu_percent;
   my $cpu_temp    = $pi->core_temp;
   my $gpio_info   = $pi->gpio_info;
   my $raspi_conf  = $pi->raspi_config;
   my $net_info    = $pi->network_info;
   my $file_system = $pi->file_system;
   my $hw_details  = $pi->pi_details;
   my $pi_model    = $pi->pi_model;

   # Pin

   my $pin = $pi->pin(5);
   $pin->mode(OUTPUT);
   $pin->write(ON);

   my $num     = $pin->num;

DESCRIPTION

This is the root module for the RPi::WiringPi system. It interfaces to a Raspberry Pi board, its accessories and its GPIO pins via the wiringPi library through the Perl wrapper WiringPi::API module, and various other custom device specific modules.

wiringPi must be installed prior to installing/using this module. The required minimum version is the family-wide constant "WIRINGPI_MIN_VERSION" in RPi::Const (currently 3.18), enforced at build time by RPi::Const::BuildCheck in each distribution's Makefile.PL - so the minimum is defined in exactly one place.

By default we use the GPIO (Broadcom (BCM) GPIO) pin numbering scheme; wiringPi's own (WPI) scheme is also available via setup => 'wiringpi'.

This module is essentially a 'manager' for the sub-modules (ie. components). You can use the component modules directly, but retrieving components through this module instead has many benefits. We maintain a registry of pins and other data, and reset the Pi back to default settings when your program ends (on normal exit, on an uncaught die(), and on SIGINT/SIGTERM), so components are not left in an inconsistent state. Component modules do none of these things.

There are a basic set of constants that can be imported. See RPi::Const.

It's handy to have access to a pin mapping conversion chart. There's an excellent pin scheme map for reference at pinout.xyz. You can also run the pinmap command that was installed by this module, or wiringPi's gpio readall command.

BASE METHODS

new([%args])

Returns a new RPi::WiringPi object. By default we use the GPIO (Broadcom (BCM) GPIO) pin numbering scheme; see the setup parameter below to select wiringPi's own (WPI) numbering instead.

Parameters:

text
setup => $string

Optional, String: Which wiringPi setup routine (and therefore pin numbering scheme) to initialize the board with. Matching is case-insensitive on the first letter:

text
'gpio'      - GPIO (BCM) numbering; the default if not sent in
'wiringpi'  - WiringPi's own (WPI) numbering
'none'      - Skip board setup entirely (the pin scheme remains
              uninitialized; primarily for testing)

Any other value will croak. Note that if another application in the process has already run a setup routine (signalled via the RPI_PIN_MODE environment variable), that existing scheme is honoured and this parameter is ignored.

text
shm_key => $string

By default, we use the key rpiw as the shared memory segment key. You can change this if desired. Useful for separating "groups" of Pi objects from one another (for example, production scripts can operate at the same time as test scripts, and both use their own shared memory pool).

text
fatal_exit => $bool

Optional: Controls what happens when we trap a SIGINT (Ctrl-C) or SIGTERM. In both cases we first reset the Pi hardware to a safe state. By default (fatal_exit true), we then re-raise the signal so the program terminates as it normally would. Set fatal_exit to false (0) to perform the cleanup and then continue running your script (eg. for unit-test work, or to allow your own signal handling to take over).

With multiple Pi objects in a single process, the signal is re-raised only if every live object has fatal_exit true; any object created with fatal_exit => 0 keeps the process running.

Note that this only affects trapped signals. Hardware cleanup on a normal exit or on an uncaught die() always happens automatically (via the object's END/ DESTROY handling); we do not trap $SIG{__DIE__}, so a die() you catch yourself with eval will not disturb your pins. Any $SIG{INT}/$SIG{TERM} handler you installed before creating the object is chained to, not replaced.

text
rpi_register => $bool

Optional: Set this value to false (0) to bypass the Pi object registration in the meta data. This will also prevent pins from being registered as well. If set to false, no object or pin cleanup will take place at the end of a program run.

text
rpi_register_pins => $bool

Optional: Similar to rpi_register, but only bypasses the pin registration. Object registration will still occur, and the object will be cleaned up after but the pins will not. Should only be used for testing.

accelerometer(%args)

Returns an RPi::Accelerometer::ADXL335 object for an ADXL335 three-axis analog accelerometer, reporting acceleration in g and tilt angle in degrees.

The Pi has no analog inputs, so the sensor's three outputs go through an ADC. You build the ADC yourself (see "adc") and hand it in, along with the ADC channel each axis is wired to. All parameters are passed straight through to the driver's constructor:

text
adc => $object

Mandatory, Object: An ADC object providing a volts() or percent() method, such as the one returned by "adc".

text
x => $int
y => $int
z => $int

Mandatory, Integer: The ADC input channels wired to the sensor's XOUT, YOUT and ZOUT pins.

text
vs => $num

Optional, Number: The sensor's supply voltage, which sets the ratiometric sensitivity and the zero-g point. Defaults to 3.3.

text
vref => $num

Optional, Number: The ADC's full-scale reference voltage, used to scale percent-only ADCs. Defaults to vs.

text
sensitivity => $num
zero_g      => $href

Optional: Override the volts-per-g sensitivity, or the per-axis zero-g voltage ({ x => ..., y => ..., z => ... }, as produced by the driver's calibrate).

Example:

text
my $adc = $pi->adc(model => 'ADS1115');

my $accel = $pi->accelerometer(
    adc => $adc,
    x   => 0,
    y   => 1,
    z   => 2,
);

my ($gx, $gy, $gz) = $accel->g;      # Acceleration, in g
my ($pitch, $roll) = $accel->tilt;   # Tilt, in degrees

See the linked documentation for the full method set, or the RPi::WiringPi::FAQ for usage examples.

adc

There are two different ADCs that you can select from. The default is the ADS1x15 series:

ADS1015

Returns a RPi::ADC::ADS object, which allows you to read the four analog input channels on an Adafruit ADS1xxx analog to digital converter.

Parameters:

The default (no parameters) is almost always enough, but please do review the documentation in the link above for further information, and have a look at the ADC tutorial section in this distribution.

MCP3008

You can also use an RPi::ADC::MCP3008 ADC.

Parameters:

text
   model => 'MCP3008'

Mandatory, String. The exact quoted string above.

text
   channel => $channel

Mandatory, Integer. 0 or 1 for the Pi's onboard hardware CS/SS CE0 and CE1 pins, or any GPIO number above 1 in order to use an arbitrary GPIO pin for the CS pin, and we'll do the bit-banging of the SPI bus automatically.

bmp($pin_base)

Returns a RPi::BMP180 object, which allows you to return the current temperature in farenheit or celcius, along with the ability to retrieve the barometric pressure in kPa.

Parameters:

text
$pin_base

Mandatory, Integer. The number at which to start the 'pseudo' GPIO pins used to communicate with the sensor. Use any value above the highest-numbered physical GPIO pin (eg. 100 or 200). See "new" in RPi::BMP180 for details.

dac

Returns a RPi::DAC::MCP4922 object (supports all 49x2 series DACs). These chips provide analog output signals from the Pi's digital output. Please see the documentation of that module for further information on both the configuration and use of the DAC object.

Parameters:

text
   model => 'MCP4922'

Optional, String. The model of the DAC you're using. Defaults to MCP4922.

text
   channel => 0|1

Mandatory, Bool. The SPI channel to use.

text
   cs => $pin

Mandatory, Integer. A valid GPIO pin that the DAC's Chip Select is connected to.

There are a handful of other parameters that aren't required. For those, please refer to the RPi::DAC::MCP4922 documentation.

dpot($cs, $channel)

Returns a RPi::DigiPot::MCP4XXXX object, which allows you to manage a digital potentiometer (only the MCP4XXXX versions are currently supported).

See the linked documentation for full documentation on usage, or the RPi::WiringPi::FAQ for usage examples.

gps

Returns a GPSD::Parse object, allowing you to track your location.

The GPS distribution requires gpsd to be installed and running. All parameters for the GPS can be sent in here and we'll pass them along. Please see the link above for the full documentation on that module.

gyro(%args)

Returns an RPi::Gyro::MPU6050 object for an MPU-6050 six-axis (accelerometer + gyroscope) IMU on the I2C bus. It reads tilt angle from gravity, angular rate from the gyroscope, and die temperature, with software gyro calibration and a deadband smoothing filter.

All parameters are passed straight through to the driver's constructor; all are optional:

text
device => $str

Optional, String: The I2C device path. Defaults to /dev/i2c-1.

text
addr => $int

Optional, Integer: The I2C address, 0x68 (AD0 low, the default) or 0x69 (AD0 high).

text
accel_range => $int
gyro_range  => $int

Optional, Integer: The full-scale accelerometer range (2, 4, 8 or 16 g) and gyroscope range (250, 500, 1000 or 2000 deg/s). Each defaults to the chip's most sensitive setting.

text
gyro_offsets => $href

Optional, Hash Reference: Per-axis gyro zero-rate offsets ({ x => ..., y => ..., z => ... }), as produced by the driver's calibrate_gyro.

See the linked documentation for the full method set, or the RPi::WiringPi::FAQ for usage examples.

hcsr04($trig, $echo)

Returns a RPi::HCSR04 ultrasonic distance measurement sensor object, allowing you to retrieve the distance from the sensor in inches, centimetres or raw data.

Parameters:

text
   $trig

Mandatory, Integer: The trigger pin number, in GPIO numbering scheme.

text
   $echo

Mandatory, Integer: The echo pin number, in GPIO numbering scheme.

hygrometer($pin)

Returns a RPi::DHT11 temperature/humidity sensor object, allows you to fetch the temperature (celcius or farenheit) as well as the current humidity level.

Parameters:

text
   $pin

Mandatory, Integer: The GPIO pin the sensor is connected to.

i2c($addr, [$device])

Creates a new RPi::I2C device object which allows you to communicate with the devices on an I2C bus.

See the linked documentation for full documentation on usage, or the RPi::WiringPi::FAQ for usage examples.

Aruino note: If using I2C with an Arduino, the Pi may speak faster than the Arduino can. If this is the case, try lowering the I2C bus speed on the Pi:

text
   dtparam=i2c_arm_baudrate=10000

lcd(...)

Returns a RPi::LCD object for an HD44780-compatible character LCD. Two wiring schemes are supported; see RPi::LCD for the display methods.

Parallel (direct GPIO) - drive the LCD's control and data lines straight from the Pi's GPIO. Send the pin configuration (BCM numbers) plus geometry:

text
my $lcd = $pi->lcd(
    rows => 4, cols => 20, bits => 4,
    rs => 5, strb => 6,
    d0 => 4, d1 => 17, d2 => 27, d3 => 22,
    d4 => 0, d5 => 0, d6 => 0, d7 => 0,
);

I2C backpack (PCF8574) - for an LCD behind a PCF8574 I2C backpack, pass i2c with the backpack's address instead of any pin configuration:

text
my $lcd = $pi->lcd(i2c => 0x27, rows => 4, cols => 20);

We register the backpack's eight expander pins as virtual GPIOs (standard wiring: P0=RS, P1=RW, P2=E, P3=backlight, P4-P7=D4-D7) and drive the panel through the same path as a parallel LCD. The backlight comes on automatically and can be switched with $lcd->backlight(0|1) (see "backlight" in RPi::LCD).

I2C-mode parameters: i2c (mandatory, the backpack address, an integer 0x03-0x77, e.g. 0x27 or 0x3F); rows and cols (mandatory, the panel geometry); and pin_base (optional, integer >= 64, default 64 - the wiringPi virtual-pin base for the expander; change it only if it collides with another pin extension). I2C mode is 4-bit and takes no GPIO pin params.

oled([$model], [$i2c_addr], [$display_splash_page])

Returns a specific RPi::OLED::SSD1306 OLED display object, allowing you to display text, characters and shapes to the screen.

Currently, only the 128x64 size model is offered, see the RPi::OLED::SSD1306::128_64 documentation for full usage details.

Parameters:

text
$model

Optional, String: The screen size of the OLED you've got. Valid options are 128x64, 128x32 and 96x16. Currently, only the 128x64 option is valid, and it's the default if not sent in.

text
$i2c_addr

Optional, Integer: The I2C address of your display. Defaults to 0x3C if not sent in.

text
$display_splash_page

Optional, Bool: Whether to display the splash page when the display is initialized. Defaults to true (1); send in 0 to skip it.

pin($pin_num, $comment)

Returns a RPi::Pin object, mapped to a specified GPIO pin, which you can then perform operations on. See that documentation for full usage details.

Parameters:

text
$pin_num

Mandatory, Integer: The pin number to attach to.

text
$comment

Optional, String: A label stored alongside the pin's registration (visible in the metadata store and used by the test suite). Defaults to none.

radar(%args)

Returns an RPi::Radar::RCWL0516 object for an RCWL-0516 microwave motion sensor, which drives its OUT pin high while it detects movement. See the RPi::Radar::RCWL0516 documentation for full usage details.

Parameters:

text
pin

Mandatory, Integer: The BCM GPIO pin wired to the sensor's OUT terminal.

text
poll

Optional, Float: The interval, in seconds, between reads when polling with wait_for_motion/wait_for_clear. Defaults to 0.1.

Example:

text
my $radar = $pi->radar(pin => 7);

if ($radar->motion){
    print "movement detected\n";
}

$radar->wait_for_motion;        # block until movement
$radar->wait_for_clear(10);     # then until clear, or 10s elapse

rtc

Creates a new RPi::RTC::DS3231 object which provides access to the DS3231 or DS1307 real-time clock modules.

See the linked documentation for full documentation on usage, or the RPi::WiringPi::FAQ for some usage examples.

Parameters:

text
   $i2c_addr

Optional, Integer: The I2C address of the RTC module. Defaults to 0x68 for the DS3231 unit.

eeprom

Creates and returns a new EEPROM object for reading and writing to. Defaults to an RPi::EEPROM::AT24C32 (4 KB, addresses 0-4095, default i2c address 0x57); pass chip => 'AT24C256' to get an RPi::EEPROM::AT24C256 instead (32 KB, addresses 0-32767, default i2c address 0x50).

Parameters:

text
chip => 'AT24C32'

Optional, String. Which EEPROM device to instantiate; one of AT24C32 (the default) or AT24C256.

All remaining parameters are passed through to the selected device's constructor. Each chip supplies its own address/device/delay defaults (notably the differing default i2c address above), all of which you may override:

text
# AT24C32 at its default 0x57
my $eeprom = $pi->eeprom;

# AT24C256 at its default 0x50
my $eeprom = $pi->eeprom(chip => 'AT24C256');

# AT24C256 at a strapped address
my $eeprom = $pi->eeprom(chip => 'AT24C256', address => 0x51);

See the linked documentation for full documentation on usage, parameters or the RPi::WiringPi::FAQ for some usage examples.

expander

Creates a new RPi::GPIOExpander::MCP23017 GPIO expander chip object. This adds an additional 16 pins across two banks (8 pins per bank).

See the linked documentation for full documentation on usage, or the RPi::WiringPi::FAQ for some usage examples.

Parameters:

text
   $i2c_addr

Optional, Integer: The I2C address of the device. Defaults to 0x20.

text
   $expander

Optional, String: The GPIO expander device type. Defaults to MCP23017, and currently, this is the only option available.

serial($device, $baud)

Creates a new RPi::Serial object which allows basic read/write access to a serial bus.

See the linked documentation for full documentation on usage, or the RPi::WiringPi::FAQ for usage examples.

NOTE: On the Pi 3 and Pi 4, Bluetooth occupies the primary UART, leaving the header pins (14, 15) on the mini-UART (/dev/ttyS0). To put the full PL011 UART back on the header you must disable Bluetooth in the /boot/firmware/config.txt file (/boot/config.txt on releases before Bookworm):

text
dtoverlay=pi3-disable-bt-overlay

On the Pi 5, Bluetooth has its own dedicated UART, so no disable-bt overlay is needed; simply enable the header UART (/dev/ttyAMA0) with enable_uart=1.

servo($pin_num)

This method configures PWM clock and divisor to operate a typical 50Hz servo, and returns a special RPi::Pin object. These servos have a left pulse of 50, a centre pulse of 150 and a right pulse of 250. On exit of the program (or a crash), we automatically clean everything up properly.

Parameters:

text
   $pin_num

Mandatory, Integer: The pin number (technically, this *must* be 18 on the Raspberry Pi 3, as that's the only hardware PWM pin.

text
   %pwm_config

Optional, Hash. This parameter should only be used if you know what you're doing and are having very specific issues.

Keys are clock with a value that coincides with the PWM clock speed. It defaults to 192. The other key is range, the value being an integer that sets the range of the PWM. Defaults to 2000.

Example:

text
   my $servo = $pi->servo(18);

   $servo->pwm(50);  # all the way left
   $servo->pwm(250); # all the way right

shift_register($base, $num_pins, $data, $clk, $latch)

Allows you to access the output pins of up to four 74HC595 shift registers in series, for a total of eight new output pins per register. Numerous chains of four registers are permitted, each chain uses three GPIO pins.

Parameters:

text
   $base

Mandatory: Integer, represents the number at which you want to start referencing the new output pins attached to the register(s). For example, if you use 100 here, output pin 0 of the register will be 100, output 1 will be 101 etc.

text
   $num_pins

Mandatory: Integer, the number of output pins on the registers you want to use. Each register has eight outputs, so if you have a single register in use, the maximum number of additional pins would be eight.

text
   $data

Mandatory: Integer, the GPIO pin number attached to the DS pin (14) on the shift register.

text
   $clk

Mandatory: Integer, the GPIO pin number attached to the SHCP pin (11) on the shift register.

text
   $latch

Mandatory: Integer, the GPIO pin number attached to the STCP pin (12) on the shift register.

spi($channel, $speed)

Creates a new RPi::SPI object which allows you to communicate on the Serial Peripheral Interface (SPI) bus with attached devices.

See the linked documentation for full documentation on usage, or the RPi::WiringPi::FAQ for usage examples.

stepper_motor(%args)

Creates a stepper motor driver object. Two drivers are supported, selected by the model parameter:

  • ULN2003 (the default) - an RPi::StepperMotor object driving a 28BYJ-48 unipolar motor through a ULN2003.
  • A4988 - an RPi::StepperMotor::A4988 object driving a bipolar motor through an Allegro A4988 microstepping driver, with software microstep selection and power-state control.

Both drivers can run either straight off the Pi's GPIO header, or off an RPi::GPIOExpander::MCP23017 passed as the expander param, in which case the pin numbers name the expander's 0-15 lines instead of Pi GPIOs.

See the linked driver documentation for full usage instructions and every optional parameter. The common parameters are:

text
model => 'ULN2003'|'A4988'

Optional, String: Which driver to build. Defaults to ULN2003 (the original 28BYJ-48 driver). Case-insensitive.

text
expander => $object

Optional, Object: An RPi::GPIOExpander::MCP23017 instance (see "expander"). When supplied, the motor is driven from the expander's pins rather than the Pi's own GPIO.

ULN2003 parameters

text
pins => $aref

Mandatory, Array Reference: The ULN2003 has four data pins, IN1, IN2, IN3 and IN4. Send in the GPIO pin numbers in the array reference which correlate to the driver pins in the listed order.

text
speed => 'half'|'full'

Optional, String: By default we run in "half speed" mode. Essentially, in this mode we run through all eight steps. Send in 'full' to double the speed of the motor. We do this by skipping every other step.

text
delay => Float|Int

Optional, Float or Int: By default, between each step, we delay by 0.01 seconds. Send in a float or integer for the number of seconds to delay each step by. The smaller this number, the faster the motor will turn.

A4988 parameters

text
step => $int
dir  => $int

Mandatory, Integer: The GPIO (or expander) pins wired to the A4988's STEP and DIR inputs.

text
ms1 => $int
ms2 => $int
ms3 => $int

Optional, Integer: The pins wired to the microstep-select inputs, all three together or none. With them wired, the resolution is selectable from software.

text
enable => $int
sleep  => $int
reset  => $int

Optional, Integer: The pins wired to the active-low ENABLE, SLEEP and RESET lines, enabling the matching power-state methods.

text
rpm           => $num
steps_per_rev => $int
mode          => $str

Optional: The stepping speed in motor RPM (default 60), the motor's full steps per revolution (default 200), and the initial microstep resolution (full, half, quarter, eighth or sixteenth; default full).

Example:

text
my $sm = $pi->stepper_motor(
    model => 'A4988',
    step  => 23,
    dir   => 24,
    ms1   => 17,
    ms2   => 27,
    ms3   => 22,
    rpm   => 120,
);

$sm->cw(360);   # One full turn clockwise
$sm->mode('sixteenth');
$sm->ccw(90);

tft(%args)

Returns an RPi::TFT::ST7735S object for a 1.44" 128x128 RGB TFT LCD driven by the ST7735S controller over the 4-wire SPI bus, allowing you to draw pixels, shapes and text to the screen in 16-bit colour.

See the RPi::TFT::ST7735S documentation for full usage details and every optional parameter. The common ones:

text
model

Optional, String: Which controller to build. Defaults to ST7735S, the only one currently supported. Case-insensitive.

text
dc

Mandatory, Integer: The GPIO pin wired to the display's D/C (data/command) line.

text
channel

Optional, Integer or hashref. Default 0. The SPI channel: 0 or 1 for the hardware chip select pins CE0/CE1, any GPIO pin above 1 to use as the chip select instead, or a hashref of RPi::SPI bit-bang parameters.

text
rst

Optional, Integer: The GPIO pin wired to the display's RES reset line.

text
bl

Optional, Integer: The GPIO pin wired to the display's BLK backlight line.

Example:

text
my $tft = $pi->tft(
    dc  => 25,
    rst => 24,
    bl  => 23,
);

$tft->clear;
$tft->fill_screen(0x001F);              # blue
$tft->string(6, 6, "Hello, Pi!", 0xFFFF, 0x0000);

CORE PI SYSTEM METHODS

Core methods are inherited in and documented in RPi::WiringPi::Core. See that documentation for full details of each one. I've included a basic description of them here.

gpio_layout

Returns the GPIO layout, which in essence is the Pi board revision number.

io_led

Turn the disk IO (green) LED on or off.

pwr_led

Turn the power (red) LED on or off.

identify

Toggles the power led off and disk IO led on which allows external physical identification of the Pi you're running on.

label

Sets an internal label/name to your RPi::WiringPi Pi object.

pin_scheme

Returns the current pin mapping scheme in use within the object.

pin_map

Returns a hash reference mapping of the physical pin numbers to a pin scheme's pin numbers.

pin_to_gpio

Converts a pin number from any non-GPIO (BCM) scheme to GPIO (BCM) scheme.

wpi_to_gpio

Converts a wiringPi pin number to GPIO pin number.

phys_to_gpio

Converts a physical pin number to the GPIO pin number.

pwm_range

Set/get the PWM range.

pwm_mode

Set/get the PWM mode.

pwm_clock

Set/get the PWM clock.

registered_pins

Returns an array reference of all pin numbers currently registered in the system. Used primarily for cleanup functionality.

register_pin

Registers a pin with the system for error checking, and proper resetting in the cleanup routines.

unregister_pin

Removes an already registered pin.

cleanup

Cleans up the entire system, resetting all pins and devices back to the state we found them in when we initialized the system. It also releases any armed interrupts (via WiringPi::API::stop_interrupts()) - stopping the wiringPi ISR threads and closing the event pipe - so you don't have to do that yourself at teardown.

Only the process that created the object performs the cleanup: in a forked child the call is a no-op, so a child can't reset pins or mutate the shared metadata on the parent's behalf when it exits.

ADDITIONAL PI SYSTEM METHODS

We also include in the Pi object several hardware-type methods brought in from RPi::SysInfo. They are loaded through RPi::WiringPi::Core via inheritance. See the RPi::SysInfo documentation for full method details.

text
   my $mem_percent = $pi->mem_percent;
   my $cpu_percent = $pi->cpu_percent;
   my $cpu_temp    = $pi->core_temp;
   my $gpio_info   = $pi->gpio_info;
   my $raspi_conf  = $pi->raspi_config;
   my $net_info    = $pi->network_info;
   my $file_system = $pi->file_system;
   my $hw_details  = $pi->pi_details;

cpu_percent

Returns the current CPU usage.

mem_percent

Returns the current memory usage.

core_temp

Returns the current temperature of the CPU core.

gpio_info

Returns the current status and configuration of one, many or all of the GPIO pins.

raspi_config

Returns the live vcgencmd get_config values plus the non-comment directives from the active config.txt (/boot/firmware/config.txt on Bookworm and later, falling back to /boot/config.txt on older releases).

network_info

Returns the network configuration of the Pi, via ifconfig where the net-tools package is installed, falling back to ip addr where it is not (as on current Raspberry Pi OS Lite).

file_system

Returns current disk and mount information.

pi_details

Returns various information on both the hardware and OS aspects of the Pi.

pi_model

Returns the normalized Raspberry Pi board name (eg. Raspberry Pi 5 Model B Rev 1.1), read from the devicetree model with a /proc/cpuinfo revision-code decode fallback. Works across the Pi 0 through 5.

INTERRUPT METHODS

Arm an interrupt on a pin with $pin->set_interrupt($edge, $callback) (see RPi::Pin). As of WiringPi::API 3.18 the callback must be a code reference, and it runs in your own interpreter when you service the interrupt rather than in the wiringPi ISR thread. The following methods drive that dispatch. See Interrupt usage in the FAQ for a complete example.

wait_interrupts($timeout_ms)

Blocks until an edge arrives or $timeout_ms milliseconds elapse, then runs all pending interrupt callbacks. Returns the number of callbacks dispatched. Call it in a loop to handle interrupts:

text
$pi->wait_interrupts(1000) while 1;

run_interrupt_loop($timeout_ms, $max)

A blocking dispatch loop, so you don't have to write the wait_interrupts ... while 1 yourself. Repeatedly dispatches and returns the total number of events handled. It runs until $pi->stop_interrupt_loop is called (from a callback or a signal handler) or, if you pass $max, until that many events have been dispatched.

text
$pi->run_interrupt_loop;        # block, dispatching, until stop_interrupt_loop

Parameters:

text
$timeout_ms

Optional, Integer: The per-iteration poll granularity in milliseconds (how long each underlying wait_interrupts blocks waiting for an edge). Defaults to 1000.

text
$max

Optional, Integer: The maximum number of events to dispatch before returning. If omitted, the loop only ends when $pi->stop_interrupt_loop is called.

stop_interrupt_loop

Breaks out of run_interrupt_loop at the next iteration. Safe to call from a callback or a signal handler.

dispatch_interrupts

Runs all pending interrupt callbacks without blocking, and returns the number dispatched. Use this instead of wait_interrupts when you already block elsewhere (eg. in your own event loop).

stop_interrupts

Releases every armed interrupt: stops the wiringPi ISR threads and closes the event pipe. The object's cleanup calls this for you automatically, so you only need it to disarm interrupts while the program keeps running.

last_interrupt

Returns a hash reference describing the most recently dispatched interrupt event - { pin, pin_bcm, edge, status, ts_us } - or undef if none has fired yet. Because the callback only receives ($edge, $timestamp_us), this lets it (or your main loop) recover the BCM pin and status; useful when one handler is armed on several pins. Like auto_dispatch_interrupts, it reports a process-wide value (the last event on any pin), so it lives on the Pi object.

auto_dispatch_interrupts($bool, $signal)

Enables (1) or disables (0) async auto-dispatch for the whole process. When enabled, $pin->set_interrupt callbacks fire automatically at Perl safe points (via SIGIO) with no wait_interrupts/dispatch_interrupts loop, and may touch your program's variables with no locking. The optional $signal picks the delivery signal (default SIGIO; pass eg 'USR1' to avoid clashing with other SIGIO users). This is a process-global switch (it affects every armed pin), which is why it lives on the Pi object rather than on an individual pin. A long, non-yielding C/XS call defers the callback until it returns - use $pin->background_interrupt (see RPi::Pin) if you need it to fire even then.

interrupt_buffer($bytes)

Gets (no argument) or sets the capacity of the interrupt queue - the kernel pipe that absorbs edge bursts. On overflow the newest edges are dropped (never merged or blocked) and counted, so raise this if a fast source outpaces your dispatch. May be set before arming and persists across teardown. Process-wide, so it lives on the Pi object. See interrupt_buffer in WiringPi::API for details.

interrupt_dropped

Returns the running total of interrupt events dropped because the queue (see interrupt_buffer) overflowed. A non-zero count means a source is outpacing your dispatch - raise interrupt_buffer or dispatch more often. Process-wide, so it lives on the Pi object. See interrupt_dropped in WiringPi::API for details.

background_interrupts([$pin, $edge, $callback, $debounce], ...)

Handles many pins in a single background child (rather than one child per pin via $pin->background_interrupt). Pass one array-ref spec per pin; the returned handle adds $h->arm($pin) / $h->disarm($pin) (toggling pins registered at creation) to the usual stop/pid/running. Because it spans several pins it lives on the Pi object, not on a single pin. See background_interrupts in WiringPi::API for details.

Dependency note: the per-pin $pin->background_interrupt form referenced above requires RPi::Pin 3.1802 or greater (the version this distribution already requires). To drive multiple pins from a single background child rather than one child per pin, use this $pi->background_interrupts method.

worker(\&body, \%opts)

Runs \&body as a hands-off background task, hiding the spawn mechanism, the loop, and the lifecycle - the GPIO sibling of background_interrupts. By default it forks a child (no use threads required) that runs body repeatedly, and returns a WiringPi::API::Worker handle:

text
pin_mode(2, 1);                                   # OUTPUT, once in main

my $w = $pi->worker(sub {
    digital_write(2, 1); sleep 1;
    digital_write(2, 0); sleep 1;
});

# ... main does its own work ...

$w->stop;                                         # idempotent

The handle carries $w->stop (idempotent), $w->pid, and $w->running, matching the interrupt handle. You normally need not call stop at all: $pi->cleanup (and therefore DESTROY) automatically stops every worker started through this method, and a forked child never reaps the parent's workers.

\%opts mirrors WiringPi::API::worker() exactly:

  • once => 1 - run body a single time instead of looping.
  • interval => $secs - pace each pass (periodic sampler/blink) instead of letting body set its own cadence.
  • shared => 1 - publish body's return value as a lossy latest value; read it from the parent with $w->value.
  • results => 1 - stream every defined return value back; drain it with $w->read or select on $w->fh.
  • mechanism => 'fork' | 'thread' - default fork (works on any Perl). thread uses an ithread for shared-memory ergonomics and requires threads to be loaded (croaks otherwise). Under thread mode, serialise shared GPIO access yourself with WiringPi::API::pi_lock / WiringPi::API::pi_unlock; the fork default never locks. See RPi::WiringPi::WORKERS for the full OO threads/worker story.

All argument validation happens in the low-level layer, so an invalid body, interval, or mechanism croaks before anything is spawned. See worker in WiringPi::API and RPi::WiringPi::WORKERS for full details.

RUNNING TESTS

Please see RUNNING TESTS in the FAQ.

TROUBLESHOOTING

Please read through the SETUP section in the FAQ.

AUTHOR

Steve Bertrand, steveb@cpan.org

COPYRIGHT AND LICENSE

Copyright (C) 2016-2026 by Steve Bertrand

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.18.2 or, at your option, any later version of Perl 5 you may have available.

Parts

28
QtyValueFootprintReferences
4330Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_HorizontalR1, R2, R3, R4
4MH_2.2mm_M2MountingHole:MountingHole_2.2mm_M2MH1, MH2, MH3, MH4
20.1 µFCapacitor_THT:C_Disc_D5.0mm_W2.5mm_P2.50mmC1, C2
24K7Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_HorizontalR5, R6
110 µFCapacitor_THT:CP_Radial_D5.0mm_P2.50mmC3
1JST_IN_PWRConnector_JST:JST_XH_B4B-XH-A_1x04_P2.50mm_VerticalJ1
1JST_IN_SIGConnector_JST:JST_XH_B5B-XH-A_1x05_P2.50mm_VerticalJ2
1JST_IO_A4_7Connector_JST:JST_XH_B4B-XH-A_1x04_P2.50mm_VerticalJ6
1JST_IO_B0_3Connector_JST:JST_XH_B4B-XH-A_1x04_P2.50mm_VerticalJ7
1JST_IO_B4_7Connector_JST:JST_XH_B4B-XH-A_1x04_P2.50mm_VerticalJ8
1JST_OUT_COILConnector_JST:JST_XH_B4B-XH-A_1x04_P2.50mm_VerticalJ5
1JST_OUT_PWRConnector_JST:JST_XH_B3B-XH-A_1x03_P2.50mm_VerticalJ3
1JST_OUT_SWConnector_JST:JST_XH_B2B-XH-A_1x02_P2.50mm_VerticalJ4
1LED_BRD_CONNLED_THT:LED_D5.0mmD4
1LED_CCWLED_THT:LED_D5.0mmD2
1LED_CENTRELED_THT:LED_D5.0mmD3
1LED_CWLED_THT:LED_D5.0mmD1
1LED_SWButton_Switch_THT:SW_DIP_SPSTx04_Slide_6.7x11.72mm_W7.62mm_P2.54mm_LowProfileSW1
1MCP23017_0x20Package_DIP:DIP-28_W7.62mmU1
1MCP23017_0x21Package_DIP:DIP-28_W7.62mmU2

More from stevieb9/rpi-wiringpi

3

Similar boards

  • 2 layers44.5 × 72.7 mmOSO SWAT C1-jig, the printed circuit board in 3D

    OSO SWAT C1-jig

    joeycastillo/Sensor-Watch

    A board replacement for the classic Casio F-91W wristwatch

    28 parts2.1k
  • 2 layers95 × 54 mmEinkPDA screen, the printed circuit board in 3D

    EinkPDA screen

    TalismanDesign/PocketMage_PDA

    An E-Ink PDA device using the ESP32 S3.

    28 parts2kApache-2.0
  • 2 layers45 × 45 mmSmartbuttons, the printed circuit board in 3D

    Smartbuttons

    hackclub/OnBoard

    💡 Join 1,000 teenagers and make your first PCB with a $100 grant!

    28 parts915
  • 2 layers24.1 × 36.2 mmEsp32miniBT, the printed circuit board in 3D

    Esp32miniBT

    asterics/esp32_mouse_keyboard

    ESP32 implementation for HID over GATT Keyboard and Mouse (Bluetooth Low Energy). Including serial API for external modules (similar to Adafruit EZKey HID)

    28 parts911GPL-3.0
  • 2 layers34.8 × 12.2 mmInfnoise goldfingers, the printed circuit board in 3D

    Infnoise goldfingers

    waywardgeek/infnoise

    The world's easiest TRNG to get right

    28 parts854CC0-1.0
  • 2 layers55.9 × 99.1 mmStm32f0 disco Luos shield, the printed circuit board in 3D

    Stm32f0 disco Luos shield

    Luos-io/luos_engine

    Open-source and real-time orchestrator for cyber-physical-systems, to easily design, test and deploy embedded applications and digital twins.

    28 parts546MIT
  • 2 layers88 × 25 mmEleLab v2 Frontpanel a, the printed circuit board in 3D

    EleLab v2 Frontpanel a

    Chrismettal/EleLab_v2

    Cheap DIY lab system for hobbyists and the tinkering folk

    28 parts531GPL-3.0

Questions

How big is the Rpi wiringpi unit test platform board-3 PCB?

It measures 91.4 × 67.9 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Rpi wiringpi unit test platform board-3 use?

28 parts. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Rpi wiringpi unit test platform board-3 KiCad files?

From the stevieb9/rpi-wiringpi repository on GitHub, at the commit this page was made from: the board is docs/test-platform/kicad/rpi-wiringpi-unit-test-platform-board-3/rpi-wiringpi-unit-test-platform-board-3.kicad_pcb and its schematic docs/test-platform/kicad/rpi-wiringpi-unit-test-platform-board-2/rpi-wiringpi-unit-test-platform-board-2.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Rpi wiringpi unit test platform board-3 design in my own project?

Its repository states no licence, so its author keeps all rights: ask stevieb9 before reusing the design.