UK train departure screen

By David Crookes. Posted

When Chris Hutchinson had an idea to create a real-time train departure board, he got to work without delay, as David Crookes discovers

Given the time of year, we can perhaps expect some leaves on the line, slippery rain or maybe, if the weather takes a real turn for the worse, the wrong type of snow. But in any case, Chris Hutchinson will be as prepared as any commuter can be thanks to his Raspberry Pi computer. 

Maker Chris Hutchinson has a life-long interest in railways and is principal engineer at The Times and Sunday Times newspapers

Chris has had an interest in trains since he was a child and he is the principal engineer at The Times and The Sunday Times newspapers.

The railway enthusiast has developed a miniature real-time train departure board that resembles the ones adorning stations across the world. “I wanted to be aware of any delays or cancellations on the trains before heading out of the house,” he explains. “I knew I could use an app on my phone, but where’s the fun in that?”

At first, Chris took videos of the dot matrix displays at the stations he visited, making a note of the quirks in their displays and paying attention to spacing and the wording they used. “I must have taken videos of 10 or 15 different departure board variations from across the UK,” he tells us. “Based on those, I worked out the minimum dataset I’d need to display the next two services from my local station, and started looking into APIs that provided the data.”

A Raspberry Pi 3B+ connected to a £25 dot-matrix display shows real-time train departure times pulled from the TransportAPI using Python 3

Tunnel vision

Chris decided to use TransportAPI and he soon got down to coding using Python 3. He’s already found the perfect display for the project – a 256×64 SSD1322 OLED screen which he liked because it was affordable, low power, and comes in different colours. “The yellow one looked like a perfect match to the videos I had been taking,” he says. “So I ordered one, excitedly waited for the post every morning and once it arrived, I wired it up, got my code running, and couldn’t believe how brilliant it looked.”

In the meantime, Chris had found an open-source Python library for displaying graphics on OLED screens – one he says is typically used for small animations or displaying debugging data. It also had a software simulator using Pygame under the hood. “It allowed me to test my code before the real screen arrived,” Chris recalls. He’d also stumbled across an open-source set of fonts created by Daniel Hart that replicated real dot matrix departure boards and these only needed some tweaks to their size.

The SSD1322 OLED screen supports different coloured displays and is easy to connect to a Raspberry Pi computer

“Most of the heavy lifting is managed in the code and there are two key parts to it,” Chris reveals. “The first is data loading and parsing, making the appropriate network requests for my station and transforming it into a useful data structure. Second is the rendering code where I take the data and turn it into pixels on the screen.”

Now it’s up and running, Chris keeps an eye on the display ahead of his daily London commute: “The board has prevented me from getting stuck out in the rain on more than one occasion.”

Chris' real-time train departure board has prevented him getting stuck out in the rain on more than one occasion

On the rails

It also seems to have struck a chord with others. “After I first got it up and running, I shared a video of the build on Twitter and the response was phenomenal. It turns out the crossover between Raspberry Pi and train enthusiasts is pretty significant and there are already a number of forks." For example, enthusiasts have expressed a desire to connect the project to bus departure times and non-UK railway networks. "It’s been a real honour to see so many people engage with the product and take it in their own directions", says Chris.  

Quick facts

  • The screen can be bought for about £25

  • Python 3.6+ is needed to run the code

  • TransportAPI has a free tier for makers

  • An API call is made every 1–2 minutes

  • Chris’s boss wants one for The Times office

More Raspberry Pi-based smart tech ideas you could try:

From The MagPi store

Subscribe

Subscribe to the newsletter

Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.