Sunday, October 26, 2014

Anyone for Some Pi

As mentioned, our Raspberry Pi setup worked well at the recent model train show. In fact it ran well all weekend. We sort of expected that, as we have after all been using JMRI software for about 2-3 years now to wirelessly control trains. This show we just happened to cutover to using a Raspberry Pi instead of a clunky old laptop computer.


To help with running a Raspberry Pi (R-Pi) setup, you need a way to turn it off at the end of the day, and as usual there are any number of ways of doing it. The R-Pi doesn’t actually come with a button that says “Power Off”, and as with all computers, you need to shut them down correctly so that they always work for you when you turn them back on. We also don’t have a keyboard and mouse attached, as we are running in a minimal setup and hence running “headless”.

One way is of course to use an application on your phone or tablet to remote control into the R-Pi such as something like “Putty” so that you can SSH into the R-Pi to then issue a command to shut down. I have found one such app for Android devices called “ConnectBot”. I find it works quite well. If using this app, you would connect into your R-Pi and then issue a command such as “sudo shutdown –h now” to turn off the R-Pi at the end of the day. You’d then wait about 3 minutes after doing this and then turn off all the power switches.

But the best way so far we have found (Peter A in the club, pat yourself on the back) is to use an app called “SSH Button” for Android devices. 

This allows you to setup a series of commands in advance, on your Android device. Each command sequence also has the username and password embedded in it so that all you have to do is press the “button” on you Android device to make it happen. See this picture of my cheap Android phone I bought to drive trains with. Here we see 3 “buttons” I have setup so far. I can shut down the HO guys Raspberry Pi, also the N scale one as well as rebooting the N scale one. The command I used to shut down the R-Pi is of course the same as above – “sudo shutdown –h now”. But now I just press the button, wait 5 seconds and you get a small message back saying “ok” and the R-Pi starts to shut itself down – voila. Here is a screenshot of my phone with some buttons setup already:


By the way, while we are talking about Pi, the HO bunch now have a Raspberry Pi. I have finalise its setup and it has been trialled on a number of Wednesdays and Saturdays and of course functions well on the new permanent HO layout. I just now need to build a small wood shelf under the NCE DCC system to position the components for their final home and write the instructions on turning it on and turning it off.

On the subject of turning on and off, maybe for the club we might purchase a simple phone to use as a shutdown device with the above “SSH Button” app, for all the club Raspberry Pi’s. I did try the other day to use the club computer in the office, but with all the steel walls everywhere, there was bugger all wireless reception in there and hence I couldn’t connect to the layouts Raspberry Pi. The future will see.

Now on the topic of Pi, spotted the other day by Peter A in the club, was a new version of the app called “Engine Driver” for use on Android devices. For anyone familiar with driving trains by using your phone and the JMRI software, Engine Drive is what sits on your phone and allows you to drive your train(s).

The latest version was just released on the 22nd October and has a great new feature. Well, here are the updates anyway:

Adjusted speed step handling to restore proper AUTO speed behaviour
New pref to stop locos when phone goes off hook
New pref to hide speed slider, making a button-only throttle

The great new feature is the third one. So here is what you do – first download and install this latest version. Next you go into the preferences side of things for this app and tick the new feature called “Hide Speed Slider” – here, I’ll show you:


What this does is make it so you only get the left and right hand speed adjustment arrows and no slider in between. I am always adjusting too far or fast, so this allows me to ONLY adjust in smaller increments. These increments, by the way, are adjustable as per normal in the preferences area. So now I have better control of the loco and am much less likely to stuff it up with my big fat fingers.

The next photo shows the new look on the right and the old look on the left – so as our friend Aleksandr says - simples!