traintraintrain: A proof-of-concept for real-time MRT train locations from your mobile phone (Part 1)

Open Government Products
Data.gov.sg Blog
Published in
4 min readSep 3, 2018

Engineering: Chris Sng, Joel Choo, Preston Lim and Liwei, Copywriting: Preston Lim

tl;dr: We created a proof-of-concept for real-time MRT train location tracking system by putting Raspberry Pis (a simple IoT device) underneath seats in trains.

traintraintrain is a proof-of-concept project that allows commuters to track their MRT train locations in real-time from anywhere. If you’re interested in finding out more about this project and how it tracks MRT trains, read on.

Our team embarked on this project in January during our team’s hackathon. We began with the following problem statement: how can we give real-time MRT train location data to commuters without interfering with train operating systems?

In this post, we start off by describing how the project was incepted and showing some visualisations of the data we collected. In a later post, we will be sharing the technical details about how we prototyped and implemented the project, and some of the challenges we faced when working on this POC.

Why is it important to know where the MRT trains are in real-time?

An open API/dataset for MRT train locations empowers citizens to make informed decisions about public transportation on an immediate time-scale.

Imagine the following scenarios:

  1. You are on the way to work on a Monday morning. You took a 10 minute bus ride to the MRT station to realise that the station is a little more crowded than usual. Gah. There’s a train delay. And you’re stuck at the station with a whole bunch of other people who are late to work too. If only there was a way to find out if trains were operating normally before you headed towards the train station. Perhaps you would have taken a bus-only route to work instead.
    Such a situation could be avoided if you could get a push notification on your phone whenever a train delay or breakdown has been detected.
  2. You are having a night out like a fun-loving Singaporean. Drats. It is already 11:45pm. You wonder if you can still catch the last train from the closest MRT station. You get to the station and the last train leaves right before your eyes. If only you knew how much time you had before you got to the station — perhaps you could have picked up the pace and saved yourself the cost of the taxi ride home.
    Such a situation could be avoided if you could see the exact MRT stations affected by the delay on Google Maps, and search for travel options avoiding those stations or those lines.

In order to build the above-mentioned tools, however, we need to obtain real-time MRT train location data first.

Some sanity checks before we begin prototyping

Great. So we’ve established that this data is useful to commuters. But exactly how useful is this data and how much effort should we put in to? How far would we go to obtain this data?

We decided as a team that it wouldn’t make sense to touch train operating systems — we are no experts on train operating technology and won’t be able to work on it easily. Also, it wouldn’t make sense to risk affecting train operations for the sake of getting this information.

Additionally, we wanted to be able to prototype and eventually productionize this product quickly and cheaply.

In summary, we wanted to:

  • obtain real-time MRT location data
  • without touching train operating systems
  • at low cost
  • and quickly/easily

How it works: WiFi routers as a data source?

Each station on the NEL has WiFi coverage courtesy of Wireless@SG. And each WiFi access point (i.e. router) has a unique ID (i.e. BSSID).

We started by collecting a list of known WiFi router IDs in each station. Next, we placed Raspberry Pis — IoT devices capable of scanning for WiFi router IDs — on trains. We then use the WiFi scans to identify where the trains are.

A visualisation of MRT trains

The final product was a basic frontend web page that displayed the locations of the 5 CCL trains being tracked in this trial. Do note that we have since moved our trial from SMRT’s CCL to SBS(T)’s NEL.

You can take a look at the dashboard using this link: http://datagovsg.github.io/ttt-frontend (Disclaimer: It is possible to have none of the trains running.)

Real-time locations of the 5 CCL trains — where are the trains now?
Historical locations of the 5 CCL trains — where did the trains travel to in the past hour?

We will dive into the implementation details, technical considerations and challenges in a later post. Stay tuned for more updates.

--

--

Open Government Products
Data.gov.sg Blog

We are Open Government Products, an experimental division of the Government Technology Agency of Singapore. We build technology for the public good.