Saturday, March 7, 2020

Departure Board

Update: I have released the source for this, which is owned but not officially supported by Google. My partner named it the Charlie Board. It can be found at https://github.com/epw/charlie-board.

I live on a fairly busy road, with three bus lines that go past my house in both directions. They have stops within a two minutes' walk from my house. But, being the MBTA, their actual timing is random and unpredictable.

However, the MBTA does deserve some credit. All the buses are now equipped with GPS, and their locations are easily queryable using the MBTA v3 API.

I decided to make a departure board, like the Cambridge Public Library has.


The departure board consists of a flatscreen monitor mounted to the wall in my front hall, with a Raspberry Pi for the brains. The Pi runs a Web server with a page that queries the MBTA and displays upcoming departures. The page refreshes once a minute. Finally, the Pi is configured to start Chrome in "Kiosk mode" when it boots, making a fullscreen version of the page with no extra Chrome popup messages (like "Restore session?"). Together, this makes the board function easily with its one purpose, providing information that is as up-to-date as possible even if the Pi spontaneously reboots.

I iterated on the UI, starting with a very simple one that showed the data coming through:

Before moving to the current setup, that uses a background that is less bright, particularly at night, and making the values much more reader-friendly.

To save power when it isn't being used, I added a pair of cron jobs to turn the screen off at 1am and back on at 5am. This still wastes some power, when no-one is home, but as I haven't been able to make a presence detector yet, this still turns it off for 4 hours a day when it surely wouldn't help.

crontab:
0 5 * * * /home/pi/bin/turn-on-screen
0 1 * * * /home/pi/bin/turn-off-screen
turn-on-screen:
vcgencmd display_power 1 > /dev/null
turn-off-screen:
vcgencmd display_power 0 > /dev/null
 
I think these should work for any HDMI screen controlled by a Raspberry Pi, but this is the only one I've tested it on.

I also have slowly added trains as they became useful. I'm looking forwards to adding Green Line trains when the new stop opens, since it's not much further from my house than the bus stops are.



What Comes Next?

This has been pretty stable. I don't have to make changes very often these days, and changes are easy when I do need to. It's been serving its purpose, making it easy to plan when trying to get somewhere in a hurry, and encouraging me to head outside for a trip when I don't have much to do.

The main limitation is that it's just in the one place. And it's true, there are lots of other sources of MBTA information, like the useful Transit app, but the screen shows the value of having the departure information available at just a thought, without even having to take out a phone.

I don't want to put screens for this all over my house, but I do have Google Homes on every floor. This seems like the next place to go. Making it answer "When does the CT2 bus leave?" would probably be quite useful.