VästtraPi: A Personal Bus Stop for Västtrafik Buses

Story

The following article was originally published in my blog.

In Gothenburg we are fortunate enough to have the local public transportation company, Västtrafik, maintaining its live schedule online and providing public API for whoever needs to query it for their own applications. Consequently, there are plenty mobile solutions that provide access to the schedule, allow you to plan your trip etc. I have a problem though. In order to figure out when the next bus is arriving, I have to take my phone out, open the application, tap on my bus stop and finally check how many minutes I have left until I miss the busvasttrapi a personal bus stop for vasttrafik buses

Being the time optimist that I am, I am usually late and cannot afford to dedicate the ~20 seconds that are needed to perform this series of actions. I want to get the information instantly, just as I do when looking at the physical departure screen on the bus stop near my apartment. So I decided to make my own bus stop screen!

So, is this faster than the mobile app solution? Yes and no. The Raspberry Pi Zero W needs around 30 seconds to boot up and display the GUI. Without any optimizations it is naturally slower than my phone. VasttraPi's biggest advantage is that it allows me to multitask while it is loading. I merely need to tap the button, carry on with my other morning preparations and just glance at the departures screen whenever I need to find out how much time I have left. The device will shut down by itself after 10 minutes.

To make a bus stop screen, the first thing you need is… a screen. A big one for that matter, that is able to receive HDMI input and will not be expensive. I found this 7″ LCD screen from China that satisfies the previous criteria for about 22$ including shipping.

A Raspberry Pi Zero W would be the component that fetches the necessary information from Västtrafik's API and generates the GUI. This versatile Raspberry Pi model combines a small form factor, low price and on-board connectivity so I have bought a couple of them as they suit a great number of use cases. The Raspberry Pi Zero W is nonetheless a full fledged computer, therefore consumes a considerable amount of power. Neither did I want to have a Raspberry Pi continuously on or have it manually plugged in and out of the power socket every time I use it. The process of turning on and off the Raspberry Pi had to be automated.

Designing a power control board solved this issue. The board sports a relay that power manages the Raspberry Pi and the driver board for the LCD screen. It is being driven by an ATtiny85 microcontroller that is connected to a capacitive touch button. I also added a CH340 serial to USB chip to establish a line of UART communication between the Pi and the ATtiny. The idea was that the microcontroller could instruct the Pi to gracefully turn off without putting a strain on the Pi's SD card. It is also there as a future-proofing mechanism, in case we will need to increase the amount of interaction between the system and the user (e.g. display weather information when upon a double tap).

The operation of the ATtiny85 is rather simple. The microcontroller is in a deep sleep state until a user taps the button and the system goes live. Then the microcontroller powers up the system for 10 minutes and extra time is added every time the button is tapped. Once it is time to turn the system off, a command is send via UART to the Pi, next we wait for some time to allow the Pi to shutdown and finally turn the power off and go to deep sleep. I ordered the boards from OSHPark.com and you can quickly purchase your own from here.vasttrapi a personal bus stop for vasttrafik buses

On the Raspberry Pi, a Python script that uses Tkinter to generate graphics is launched on startup, goes full screen and turns off the Pi's screensaver. Then it periodically fetches bus trips towards the city center from a nearby stop and presents them on the screen. Thus far, the bus station, selected platform and bus line destinations that are displayed are hard-coded, as I do not have the need nor the time to develop a more generic solution. That being said, it should not be difficult to adjust this to other stops and different bus lines.

For more detail: VästtraPi: A Personal Bus Stop for Västtrafik Buses


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top