When’s the Next Train Coming? Creating a Simple Next Arrival Display with Raspberry Pi and Python
This year I’ve been riding my bike, the SunRail, and LYNX buses pretty regularly to the co-working space where I work. It’s a really cool industrial space right next to a train station, so it keeps me thinking about transportation.
The past two weeks I’ve been doing some research related to public transit, in Central Florida and in general, looking for a way to insert myself and my skills and passions into an ecosystem with a lot of problems.
As a bit of a break from all the reading and learning, I wanted to make something. I decided to start simple, with the goal of making a little sign that told me when the next train was coming. There are signs on the platform, but they don’t currently show any information about when the train is coming. SunRail’s website shows the information, but it’s hard to get to and I don’t always want to have it open. And the schedule is sporadic enough that it’s not super easy to memorize.
I’d rather have the exact information right next to me, all the time, so I can just glance over at it. Kind of like this personalized transit clock but even simpler.
I happened to have an extra Raspberry Pi and character LCD lying around (another motivation to make something), so I followed this tutorial from Adafruit to get things up and running:
After that, it was a matter of getting the Pi connected to WiFi so the time was correct, and writing some Python code to calculate the time until the next northbound and southbound trains. Since I was treating this as an MVP, I just hard coded the schedule for this particular train route and station:
Instead of hard-coded arrival times, a next step could be to use GTFS (loaded locally or via an API) or better yet, the new Transitland Datastore API, configurable to a particular agency, route, and stop. And when there is a GTFS-realtime feed for SunRail (I’m speaking that into existence), that could be used instead of the scheduled times for more accuracy (really a requirement to be truly useful… as I see the train coming up 3 minutes early out the window right now).
I could see this prototype going in a few directions:
- low-cost realtime transit signage for outdoor public spaces
- designer object for coffee shops and other trendy businesses located near transit stops
- open hardware kit
Of course there are a lot of other things to consider if I decide to take this further in any of those directions. Power requirements, connectivity, environmental exposure, software and hardware design, industrial design of the enclosure, configuration and customization, maintenance, and more. And in general, most people are accessing this type of information via mobile phone. But I think there’s still a place for it IRL:
Originally published at nathanselikoff.com