HiPi
Perl Modules for Raspberry Pi
Version 0.85 - released 28 November 2020

HiPi::RaspberryPi

Provides information about your Raspberry Pi board.

Methods

Create a new instance of HiPi::RaspberryPi

use HiPi::RaspberryPi;
my $pi = HiPi::RaspberryPi->new();

Dumps information about your Raspberry Pi board.

print $pi->dump_board_info;

The method produces output similar to the following:

pi@raspberry:~ $ perl -MHiPi::RaspberryPi -e"print HiPi::RaspberryPi->new->dump_board_info;"
--------------------------------------------------
Raspberry Pi Board Info
--------------------------------------------------
Model Name       : Raspberry Pi 3 Model B Rev 1.2
Released         : Q1 2016
Manufacturer     : Sony
Memory           : 1024
Processor        : BCM2837
Hardware         : BCM2835
Description      : Type 3 40 pin GPIO header
Revision         : a02082
Serial Number    : 0000000012345678
GPIO Header Type : 3
Device Tree      : Yes
Is Raspberry     : Yes
Is Raspberry 2   : No
Is Raspberry 3   : Yes
Is Raspberry 4   : No

Information for the individual lines is produced using other module methods

use HiPi::RaspberryPi;
my $pi = HiPi::RaspberryPi->new();

# Model Name
my $modname = $pi->model_name();

# Released
my $released = $pi->release_date();

# Manufacturer
my $manu = $pi->manufacturer();

# Memory
my $mem = $pi->memory();

# Processor
my $proc = $pi->processor();

# Hardware
my $hware = $pi->hardware();

# Description
my $desc = $pi->board_description();

# Revision
my $rev = $pi->revision();

# Serial Number
my $serial = $pi->serial_number();

# GPIO Header Type
my $type = $pi->gpio_header_type();

# Raspberry Types
my $israsp = ( $pi->is_raspberry ) ? 'Yes' : 'No';
my $israsp2 = ( $pi->is_raspberry_2 ) ? 'Yes' : 'No';
my $israsp3 = ( $pi->is_raspberry_3 ) ? 'Yes' : 'No';
my $israsp4 = ( $pi->is_raspberry_4 ) ? 'Yes' : 'No';

Returns a descriptive model name for the Raspberry Pi board

my $mname = $pi->model_name();

Returns the release date for the Raspberry Pi board

my $date = $pi->release_date();

Returns the manufacturer name for the Raspberry Pi board

my $manu = $pi->manufacturer();

Returns the amount of memory for the Raspberry Pi board in Mb

e.g. 256, 512 or 1024

my $mem = $pi->memory();

Returns the Processor determined from Revision as displayed by cat /proc/cpuinfo

The Raspberry Pi 4 returns BCM2711. The Raspberry Pi 3 and 3+ return BCM2837. The original Raspberry Pi 2 returns BCM2836 while the 1.2 revision returns BCM2837. All other models return BCM2835

my $proc = $pi->processor();

Returns the Hardware as displayed by cat /proc/cpuinfo

All boards return BCM2835 on any recent version of Raspberry Pi OS. Versions of Raspbian several years old used to return BCM2708 or BCM2709 depending on your board model. This isn't a good method to determine the capabilites of your board. Use the other methods for that.

my $hware = $pi->hardware();

Returns a description for the Raspberry Pi board based on the GPIO header type

my $btype = $pi->board_description();

Returns the Revision as displayed by cat /proc/cpuinfo. This can be used to determine the capabilities of the board

my $rev = $pi->revision();

Returns the unique serial number for your Raspberry Pi.

my $serial = $pi->serial_number();

Returns a number representing the type of GPIO header on your board

1      26 pin header for the first Model B's with different pin out for the i2c device
2      26 pin header for the Model B rev 2 and Model A
3      40 pin header for the Pi 3, Pi 2, B+, A+, Zero and Zero Wire
4      Compute Module 3
my $type = $pi->gpio_header_type();