Many model railroaders would benefit from using smartphones as Throttles, but most are not computer experts, and may be intimidated by the setup required. To lower this bar, I've preconfigured everything needed to get started, and provide the software free of charge.
First, start with the tiny RaspberryPi computer ($40). Download my free, preconfigured image to your computer and write it to a microSD card (using Etcher). Connect your supported DCC hardware, then simply turn on main power, and the RPi will start up and load JMRI, scanning for your layout hardware connection. It will also start up a dedicated wireless network on the RPi. Within 30 seconds, you can connect your phone(s) or pad(s)to the RPi's WiFi and start running trains! The RPi needs no screen, keyboard or mouse, so it can stay nicely out of the way under the layout, or in your electronics box [photo].
Below are the details of how to get your own JMRI RaspberryPi access point for EngineDriver, WiThrottle, and WiThrottleServer-compatible devices.
Contact me [here] if you have any questions, or to let me know how the image works for you.
|RaspberryPi 4 Model B 2Gb (model 3 also works)||Newark|
|5.1V 3A Power Supply||Newark|
|16Gb MicroSD memory card (or larger)||NewEgg|
|RPi Case (**optional )||Newark|
I have built an image file which contains all software and config needed to autostart JMRI PanelPro on the RPi, as an access point, with WiThrottle Server, Web Server and LoconetOverTCP (or JMRI Simple) server included. Also included is remote access to the RPi via ssh (command line) and to the RPi "desktop" via VNCServer (at port ::5900)
Download the latest image file dated May 11, 2023 [1.4Gb xz] (JMRI 5.3.6), or one updated June 24, 2022, as [1.5Gb xz] (JMRI 5.0).
The image features:
- AutoIdentify of attached hardware (Locobuffer-USB, PR3, SPROG, LENZ USB, NCE Serial, NCE USB (Note 1), DCC-EX, EasyDCC Serial, MERG USB, MRC Prodigy)
- Autostart of JMRI PanelPro (with WiThrottle and Web Server) to match hardware connection. (enabling DecoderPro)
- Creates its own wifi access point for device connection, and/or can be wired into existing Ethernet network.
- You can upload roster files and icons via the JMRI web server.
- Web server extensions for restart/shutdown of the RPi, viewing the session.log, viewing JMRI tables, and more.
- Access to GUI desktop via attached monitor or remotely via VNC client
- Support for defining GPIO Pins as JMRI Sensors and Turnouts
- Latest Raspbian Bullseye image
- Secure file access via SCP or Windows file share.
Note 1: for NCE USB autoIdentify, remove all jumpers prior to powering on.
From a Windows computer or Mac, download the .xz to your computer, then use balenaEtcher to write the .xz file to your microSD card. (no need to unzip)
Then place the card in your RPi, connect your DCC hardware, then power on your RPi.
NOTE: always answer "No" to any "Format Drive?" or "Scan Drive?" messages.
Once you've assembled the hardware and installed the image, first connect your RPi to your layout via your system's USB or serial connector, then plug in the RPi's power adapter. You should see some LEDs on the RPi begin to blink, and shortly, using your wifi-capable phone, you'll see a WiFi network named "RPi-JMRI". Select it and enter "rpI-jmri" when prompted for the key (note that 3rd character is a capital "eye"). Open EngineDriver on your phone, and you should have an available connection under Discovered Servers named "RPi-JMRI [connection name]". (Similar with WiThrottle on iPhone). Select that server, then select a loco address and run trains!
Note: If you see "No Layout Connection!" as the Discovered Server, the autoIdentify did not identify your hardware. Retry steps above (with layout hardware attached and powered up). Or access the RPi desktop and run "Disable autoIdentify", then use PanelPro to select and (if needed) modify or create the proper Config Profile.
Accessing the RPi
You can access the JMRI Web Server at http://RPi-JMRI.local:12080. It includes buttons to "Shutdown RPi" and "Restart RPi", as well as menu options to access panels, roster, tables, operations features, and view the JMRI session log.
The RPi is always at "RPi-JMRI.local" and running VncServer, so you can use TightVNC or RealVNC client to access the desktop (use address "RPi-JMRI.local::5900"). Via the desktop, you can easily change and save settings in JMRI PanelPro. Double-click the "Disable AutoIdentify" if you'd like your RPi to always use the last profile.
You can also use remote access tools like Putty for command line, and WinSCP (use port 22) or Windows file sharing [screenshot] for file access, for tasks such as copying your roster and panel files over to the RPi. (user is "pi", all passwords are "rpI-jmri", 3rd char is a capital "eye"). Put these files in the /home/pi/JMRI_UserFiles folder. You can also upload your roster files using the JMRI Web Server's Roster page [screenshot].
Note: some devices and/or networks have issues resolving by name, so you can try "192.168.6.1" instead of "RPi-JMRI.local" in the commands above.
Remote copy of JMRI
JMRI provides some excellent tools for "sharing" a physical connection to your layout. One of these is the LoconetOverTCP server (Digitrax-only). To use this, connect a separate computer to the RPi-JMRI wifi network. On that computer, start JMRI, and in Connections, specify Digitrax, LocoNetOverTCP LbServer. Enter the RPI's address "192.168.6.1", Save and restart. When JMRI comes up, you will be running a full copy of JMRI, with full-screen access to panels, throttles, decoder programming, etc.
For non-Digitrax layouts, follow the above steps, but specify JMRI Simple Server. Specify the "System Prefix" that matches the connection on the RPi. (Note: the Simple Server only supports Turnouts, Lights, Sensors, Reporters and Power).
For more advanced modifications to your RPi-JMRI image, see [this page].
Note: the following section is for information only, and is not needed to use the RPi-JMRI image. It describes the steps I have already taken in the image provided.
UPDATE: I recently dist-update'd from the image described below to the Bullseye version.
Started with the RaspberryPi Raspbian Bullseye (desktop only) image.
Update Raspbian using "sudo apt update;sudo apt full-upgrade -y;"
Installed java, hostapd, dnsmasq and samba using "sudo apt-get install openjdk-11-jdk hostapd dnsmasq samba cups-bsd"
Set static address for wlan0 in /etc/dhcpcd.conf (to 192.168.6.1) and disabled wpa_supplicant for wlan0
Set matching address range in /etc/dnsmasq.conf (192.168.6.50 - 192.168.6.99)
Configure hostapd in /etc/hostapd/hostapd.conf with SSID name and password. Update /etc/default/hostapd to point to this settings file.
Set hostname, password, and localization options using "sudo raspi-config".
Set hdmi_group=2 and hdmi_mode=16 in config.txt to provide a default resolution for VNC.
The name is broadcast as "RPi-JMRI.local". This can be useful to identify the RPi on a wired network, handy for troubleshooting wifi problems.
Set up samba share to JMRI_UserFiles folder in /etc/samba/smb.conf, run "sudo smbpasswd -a pi" and set the samba password. This provides access from windows explorer as "\\RPi-JMRI", and also causes wins to resolve that name to an ip address.
Set the vnc password using "sudo vncpasswd -service"
Connect to the RPi using TightVNC Viewer or similar. Using the RPi's browser, download the desired Linux version of JMRI from JMRI.org, and extract it to /home/pi/JMRI on the RPi. Start a terminal session, and run ~/JMRI/PanelPro. Set WiThrottle to autostart on port 12090 (default), and the JMRI Web Server to autostart on port 12080 (default). Set the User Files location to /home/pi/JMRI_UserFiles. Set up connections as needed, saving profiles for several popular hardware connections: PR3, LocoBuffer-USB, NCE Serial, NCE USB, SPROG, EasyDCC Serial, MERG USB, MRC Prodigy or DCC++. Each has a unique "railroad name", which is shown as the Discovered Server name, this is useful for verifying your connection.
To provide external access to the JMRI log files, ran
ln -s /home/pi/.jmri/log/ /home/pi/JMRI_UserFiles/log
Log can now be accessed as "http://RPi-JMRI.local:12080/prefs/log/session.log" from any connected browser.
I added desktop icons to view userfiles and the session log, and set the background image and color. I also checked "Don't ask options on launch executable file" in File Manager Preferences.
To load PanelPro at desktop startup, I ran:
ln -s /home/pi/Desktop/PanelPro_autoIdentify.desktop /home/pi/.config/autostart/PanelPro_autoIdentify.desktop
PanelPro_autoIdentify.sh is a shell script which attempts to open PanelPro with the correct profile, based on identifying the attached hardware. To bypass this and have PanelPro always start with your last profile, double-click the desktop icon "Disable AutoIdentify".
To enable use of the RaspberryPi's GPIO pins [details here], I appended the following line to /home/pi/.profile:
and added the following value to /home/pi/.jmri/jmri.conf
To enable printing from the RPi, I ran:
sudo usermod -a -G lpadmin pi
The user can then set up printers by browsing to "http://localhost:631" from the RPi desktop. Enabling remote access is available, but not enabled by default.
To minimize the size of downloadable image, I did a bit of cleanup and set all unused space to zeroes. This helps (a lot) with the compression. Here's my cleanup script.