Site icon adambowie.com

Building a Desktop National Rail Dashboard

Building a Desktop National Rail Dashboard

For ages now I’ve been meaning to put together a home dashboard: a screen that gives me up to date information about my local railway station with the departure boards showing.

A slightly bigger ambition was to have the dashboard also display times for nearby buses – and perhaps the weather and Twitter news feeds. 

It should have been a relatively simple project, but it seems that live dashboards are either bespoke paid-for things, or are no longer properly developed.

Either way, I decided to do something relatively simple. There was something called dashing.io which is no longer maintained. In its place is a fork of it called smashing. But I couldn’t get on enormously with either.

What I specifically wanted was a dashboard that would be Raspberry Pi powered, and could make reasonable use of a small screen.

Some time ago I bought the parts, but it has been one of those projects that I started and failed to complete. So to get things going, I built a simplified version using the parts I already had:

Now in another world, I’d design something a little smarter and use some nifty CSS to make everything look nice. But as you can see from the above picture, I didn’t do that.

The hardware is relatively straightforward, and in this instance there isn’t really any software to create or install. But there are still challenges!

I’d found a handy link on a Reddit forum that presents a station departure board, hosted by National Rail. [April 2021 Update – this is the new server for TIGER, the National Rail information system: https://tiger.worldline.global/home]

This is the page for Highbury & Islington station in London. [April 2021 Update – You’re better off using this version of the Highbury & Islington information – https://tiger.worldline.global/HGHI/cisds]

I strongly suspect that this link is using someone else’s API key. I suppose I should really get my own. But it seems to be working fine. As well as a User ID, there’s space for the all-important CRS code and a mysterious H value which I’ve not quite worked out. [April 2021 Update – If you use https://tiger.worldline.global/home you won’t be misusing anyone’s API key as there are none required for his new server.]

The key thing with this is that you need to find the CRS code for the station you’re interested in – the three letter code every station in the UK has. The list of codes can be found here. [April 2021 Update – Not required if you go through the TIGER link. Just search for your station.]

While the page is a little underwhelming in design, it does scroll if needed and has neat little features like telling you where the train was last reported, so you can live track your train.

So I had a basic website that I wanted to load up. Now it’s simply a question of launching the Pi on boot, straight into Chromium (the Pi’s default browser) and show the page fullscreen – or in so-called ‘kiosk’ mode. There won’t be a keyboard attached, and the idea is that the device does one thing, and does it well.

This seemingly trivial task took me an annoyingly long amount of time to work out, because lots of people do it lots of different ways, and it seems that some methods no longer work with the current default installations of Raspbian, the main OS for Raspberry Pis. If you’re a Linux expert, then much of this might be trivial. But I’m not, and for me it wasn’t!

That all said, in the end, by carefully following the steps on this page from Die Antwort, I got it all to work using their methodology. I can confirm that this works on the current version of Raspbian (the main operating system used on the Pi) – at least at time of writing.

Note that if you buy the Pimoroni frame as I had, then you’ll want to follow these instructions which tell you how to rotate the screen 180 degrees by default, since everything will otherwise be inverted. You can do this early on after installing the Raspbian operating system below; the precise orientation you choose will depend on how you want to place the screen.

The key thing here is to only install Raspbian Lite, which doesn’t actually include a graphical user interface. But if you go step by step through the Die Antwort instructions, you should get there.

A few things to note for those who are a little uncertain:

One further amendment I needed to make to the Die Antwort instructions was to shrink the default Chromium zoom size a little. Because the Pi’s touchscreen is only 800×600, everything looked a little squashed on the screen. After experimentation, I chose 70% as an appropriate size to squeeze a bit more text onto the small screen. To fix this you should add some extra text to the Openbox configuration to scale the browser down, using the delineator –force-device-scale-factor=[decimal]. ie. for 70% of full size use:

chromium-browser --disable-infobars --kiosk --force-device-scale-factor=0.70 'http://your-url-here'

When you test it’s also working, remember that you can break out of the page by pressing Ctrl-Alt-Backspace with a keyboard plugged into the Pi.

If you follow all these instructions carefully, you should end up with something similar to me.

This all gets me up and running, but there are lots more improvements to make!

As I said at the start I had previously had bigger ideas about putting together a much more comprehensive dashboard, but aside from the touchscreen’s low resolution not being really suitable for that, you’ll notice in the background that I also have a Google Hub, and to be honest, that takes account of a lot of my needs for things like time and weather (as well as photos!). That said, I’ve still not worked out a simple way to quiz Google Assistant about train departure times. On the other hand Amazon Alexa is great when you set up the skill for your “commute”, but is painful to use for anything else. So creating this departure board is actually a useful exercise.

Hopefully this will be of use to someone else. I’m pleased with the result. It could be better, but it does the job.

Update – January 2020

Ignore this update which basically doesn’t work and is full of inaccuracies. I will properly write up some notes on what I’ve done in the near future.

This project is still working fine, but I’ve made a couple of changes to thing. First of all, I’ve changed my feed to the “TIGER” system suggested by Paul in the comments.

It’s easy to search for your station, and then you’re provided with a range of options. I’m using CIS Detailed Summary Widescreen. Note that I did have to amend the scale to make it work. I’m now using 0.5 as below:

chromium-browser --disable-infobars --kiosk --force-device-scale-factor=0.50 'http://your-url-here'

Next, I’ve use crontab to run a couple of things on regular basis. One of these fixes broken displays – when the website stops working. This most frequently happens overnight. So I’ve scheduled a daily reboot at 6.00am.

The other thing is scheduling time for the screen to be off. Again this is done in crontab.

Essentially, from a command line prompt, enter crontab -e. If it’s the first time you’ve run it, you’ll be prompted for an editor. Choose nano.

On the resulting screen you need to add three lines at the end of your file.

0 6 * * * reboot
0 22 * * * DISPLAY=:0 xset dpms force off
30 5 * * * DISPLAY=:0 xset dpms force on

Then press Ctrl-X to exit, save and close.

The first line says, at 0 minutes and 6 hours – i.e. 0600 – run a reboot. The three stars indicate date, month and day of week, but we’re not using them here.

The second line is the screen turn-off time. I’ve set mine to 2200 or 10pm. I’m unlikely to be catching trains after this hour.

The final line is the screen turn-on time. I’ve set this to 0530 which is early, but if I am catching a train at that time, I really need to know that they’re on time!

Note that I’ve scheduled the reboot when the screen is active, and at a different time to when I’ve scheduled it to come on. Hopefully this will save a bit of energy.

Obviously, I could have just not turned off all the settings that time out the screen due to inactivity, but I like to be able to glance at the information, and not have to interact with it first.

Update – April 2021

I’ve added in links to the new TIGER server – https://tiger.worldline.global/home – which began migration at the end of March 2021 according to a message on the previous page. It’s a good system with varying options for the level of detail you require.

Exit mobile version