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 ($35). Download my free, preconfigured image to your SD card. 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 from 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.
|RaspberryPi Model 3||Newark|
|5V 2.5A Power Supply w/ MicroUSB Cable||NewEgg|
|8Gb MicroSD memory card||NewEgg|
|RPi Case with Lid (**optional )||Newark|
I have created 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 zipped image file [here] (1.3Gb, updated September 27, 2018), or an earlier zipped image file [here] (1.3Gb, updated April 25, 2018).
The image features:
- AutoIdentify of attached hardware (Locobuffer-USB, PR3, SPROG, LENZ USB, NCE Serial, NCE USB, DCC++, EasyDCC Serial, MERG USB, MRC Prodigy)
- Autostart of PanelPro with WiThrottle and Web Server.
- Creates network access point for device connection, or can be plugged into existing 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 Stretch image
- Secure file access via SCP or Windows file share.
To use: From a Windows computer or Mac, download and unzip the file, then use Win32DiskImager or Etcher to write the .img file to your SD card, place the card in your RPi, connect your DCC hardware, and power the RPi on.
Contact me [here] if you have any questions, or to let me know how the image works for you.
Once you've assembled the hardware and installed the image, 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). Enter loco address and run trains!
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. 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 decoder programming, panels, etc.
For non-Digitrax layouts, follow the above steps, but specify JMRI Simple Server (Note: this server has some limitations).
The RPi is always at "RPi-JMRI.local" and running VncServer, so you can use TightVNC 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 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: 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.
Started with the June 2018 RaspberryPi Raspbian Stretch image, which includes Java 8.
Installed hostapd, dnsmasq and samba using "sudo apt-get install hostapd dnsmasq samba"
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.
Set hostname and password using "sudo raspi-config".
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 -system"
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.
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 minimize the size of downloadable image, I do a bit of cleanup and set all unused space to zeroes. This helps (a lot) with the compression. Here's my cleanup script.