Hardware Setup Support: Raspberry Pi via GPIO

The Raspberry Pi is a family of inexpensive credit card size single board computers that have many applications in embedded electronics. This page describe's the use of the Raspberry Pi's GPIO pins under JMRI. Since the Raspberry Pi runs Linux natively, other connections are also possible using either a USB connection or via the Raspberry Pi's built in serial ports.

Raspberry Pi2 model B (courtesy www.raspberrypi.org

Supported Hardware

Theoretically, any Raspberry Pi supported by Pi4J is supported by JMRI.
JMRI support has been tested with the Models B, B+, 2B, and 3. There's also a JMRI install help page for the Pi.



Underlying support for the Raspberry Pi's GPIO connections is provided using the Pi4J library for Java.

Version 1.0 of the Pi4J Library, used with JMRI version 4.5.4 and earlier, require that applications using GPIO pins be run as root (or using sudo).

Starting with version 4.5.5, JMRI uses version 1.1 of the Pi4J Library. Version 1.1 of the Pi4J library, when used in conjunction with Raspbian Jessie (and later releases) allow the user to access the GPIO pins without running as root. For compatability reasons, and to allow possible use of PWM outputs, JMRI has choosen not to enable this mode by default.

In order to enable use of the GPIO pins by a non-root user, the user must set the WIRINGPI_GPIOMEM environment variable as follows:


This environment varialbe must be set prior to executing JMRI


For more information, please see the relavent portions of the pi4j web page.

JMRI currently supports inputs (Sensors) and outputs (Turnouts) via the Raspberry Pi's GPIO pins.

Input/Output pin addressing

JMRI currently uses the default Pi4J pin numbering. The Pin numbers may differ on each model Pi. Generally speaking, Broadcom GPIO pins 0 to 7 may be referenced by those pin numbers in JMRI. This is not guaranteed to be the case. Higher pin numbers are available, but may not correspond to the Broadcom pin numberings. Please refer to the Pi4J website for model specific pin numbering information.


  1. Make sure you have the latest version of JMRI installed, then go to the Preferences panel of a JMRI-based program. This opens automatically the first time a program is run, or you can select it from the "Edit" menu
  2. Select "Raspberry Pi Foundation" from the System Manufacturer selection box.
  3. Select "Raspberry Pi GPIO" from the System Connection selection box.
  4. Click "Save". You'll be asked if it's OK for the program to quit, click "Yes".
  5. Restart the program. You should be up and running.



JMRI installation on Pi/Raspbian.

Third Party info

The Pi4J website provides model specific Java I/O information.