Skip to content

Realtime London bus stop information from TFL, on a raspberry pi, on your desktop.

License

Notifications You must be signed in to change notification settings

soinkleined/busstop

Repository files navigation

busstop

busstop

Realtime London bus stop information from TFL, on a raspberry pi, on your desktop.

Info

Busstop returns current arrival information for busses at the requested stop(s). It prints the output in a style similar to that of the live bus update signs available at many bus stops throughout London.

The script runs as a flask application and uses turbo flask web sockets to update it dynamically in 15 second intervals. It is intended to run via a raspberry pi whilst using chrome in kiosk mode.

Clone the repo:

git clone https://github.com/soinkleined/busstop.git
cd busstop

Using the TFL API, find the corresponding StopPoint(s) and add it/them to the ~/busstop_config.ini file. You can also configure the number of bussess to display per stop. By default, a config file will be installed in the config directory of the tfl_bus_monitor package.

Individual stopids can be found by looking for the arrivals at the stop via the TFL website. For example:

https://tfl.gov.uk/bus/arrivals/490015396S/newington-green/

The stopid for Newington Green is 490015396S as can be seen in the URL above. To download a reference for all stopids, TFL also makes this data available.

The column where the stopid is located is "Naptan_Atco" and you might want to validate it against the "Stop_Name":

http://tfl.gov.uk/tfl/syndication/feeds/bus-stops.csv

Here is an example configuration. Use comma-separated stopids and values for the number of busses you'd like to display for each stop. "0" will display all available busses. Keep in mind your screen size and adjust appropriately.

[busstop]
#Clissold Crescent, Newington Green
stopid = 490005432S2,490015396S
num_busses=10,10

Install a python virtual environment and all requisite packages:

cd flask_app
virtualenv venv
source venv/bin/activate
pip3 install -r requirements.txt

After cloning the repo and all requisite packages are installed, do the following:

flask --app main run

Point your browser to http://127.0.0.1:5000/

There are also wrapper scripts to start the application with flask or gunicorn.

For running the application as a service for kiosk mode, there is a work in progress in the kiosk_files folder that will have all the requisite configuration information for gunicorn, nginx, chrome, etc.

busstop web

busstop example

Hardware list

Links to the hardware:

hardware

To Do

  1. update documentation to cover tfl_bus_monitor
  2. finish kiosk build automation

Acknowledgements

Balena.io is a very interesting platform for IoT fleet management. I saw their blog post about creating a live train time sign under your monitor and was inspired to do something similar for busses. There are a lot of links to other resources from the post as well as many other project ideas.

https://www.balena.io/blog/build-a-raspberry-pi-powered-train-station-oled-sign-for-your-desk/

I used the fonts from Sean Petykowski and created webfonts via Font Squirrel. Thank you very much!

Please see the original ttf fonts here:

https://github.com/petykowski/London-Underground-Dot-Matrix-Typeface

and converted here:

https://www.fontsquirrel.com/tools/webfont-generator

Other useful links and acknowledgements:

https://blog.miguelgrinberg.com/post/dynamically-update-your-flask-web-pages-using-turbo-flask

https://jsonpathfinder.com/

https://github.com/realpython/flask-boilerplate

https://stackoverflow.com/questions/335695/lists-in-configparser

https://itecnote.com/tecnote/python-elegant-way-to-adjust-date-timezones-in-python/

https://trstringer.com/logging-flask-gunicorn-the-manageable-way/

Icons made by mavadee from www.flaticon.com

License MIT license

This project is licensed under the terms of the MIT license.

About

Realtime London bus stop information from TFL, on a raspberry pi, on your desktop.

Topics

Resources

License

Stars

Watchers

Forks