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.
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
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
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.
- 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
- Select "Raspberry Pi Foundation" from the System Manufacturer selection box.
- Select "Raspberry Pi GPIO" from the System Connection selection box.
- Click "Save". You'll be asked if it's OK for the program to quit, click "Yes".
- Restart the program. You should be up and running.
Third Party info
The Pi4J website provides model specific Java I/O information.