Skip to content

Display upcoming Port Authority of Allegheny County bus times on a scrolling LED message board

License

Notifications You must be signed in to change notification settings

saylorsd/PATransitTicker

Repository files navigation

PATransitTicker

Display upcoming Port Authority of Allegheny County bus/T times on a scrolling LED message board connected to a Raspberry Pi.

The Ticker

Required Parts

  1. RaspberryPi (pretty sure any version will work)
    a. SD Card
    b. WiFi dongle (optional: can use ethernet) (note: WiFi is built into v3 and ZeroW)
    c. USB Micro-B USB cable/charger (same as most - if not all - Android phones/tablets)
    d. HDMI Cable and HDMI compatible monitor (or necessary adapters) (for initial setup)
    e. USB Keyboard (for initial setup)
  2. MAX7219 controlled LED matrix(ces) I happened to use this one but any MAX7219-controlled LED Matrix(ces) should work (with a little coding).

Accessing TrueTime API

Make an account here to request an API key.
An account is also necessary to access the TrueTime documentation.

Hardware Installation

Check out The LED Matrix Ticker Driver used for this project for installation instructions.
If using differently hardware, you will likely need to use a different driver and follow different installation instructions.

Installation

  1. Connect Matrix to Raspberry Pi (see my LED Ticker's readme for an example)
  2. Clone this repo onto your Raspberry Pi and generate a settings file.
git clone --recursive https://github.com/saylorsd/PATransitTicker

cd PATransitTicker

cp settings-example.py settings.py
  1. Open settings.py in your favorite text editor and copy your API key in place of "YOUR_API_KEY_HERE!"
nano settings.py
  1. Adjust the other settings if necessary.
  2. Install the necessary python libraries
pip install -r requirements.txt  
  1. Run the ticker
python ticker.py

Settings

settings.py

API_KEY = "YOUR_API_KEY_HERE!"              # TrueTime API key from Port Authority

FONT = CP437_FONT_ROTATED                   # !! Change this to your font of choice (be sure to import it above!)
LOG_FILE = "/home/pi/logs/bus-ticker.log"   # Where the log file will go.  Use Falsey value to log to stdout
DURATION = 30                               # Number of minutes you want it to run for
SPEED = 5
PREDICTIONS = [
    {
        'stpid': 8161,      # stop id
        'rt': 'P3',         # bus route name
        'dir': 'INBOUND'    # direction: 'INBOUND' or 'OUTBOUND'
    },
    {
        'stpid': 18141,
        'rt': '75',
        'dir': 'INBOUND'
    }
]

The Predictions Request

This code uses the getpredictions endpoint for the TrueTime API. For this use case, it sends a bus stop ID, a route ID, and the direction (inbound/outbound).

You can find your bus stops' IDs on the Port Authority's Transit Stop Data on the Western Pennsylvania Regional Data Center. Find your stop on the map, click it, and look for 'ID' in the popup.

More info can be found in the documentation. (requires you to be logged into the TrueTime site first)

Cron Job

I built this around my use case wherein I run this script as a cron job that starts around the time I'm getting ready in the morning. For those unfamliar with cron, here's a nice resource.

To edit your cron jobs:
crontab -e
Then add a line like this:
0 7 * * * python /path/to/ticker.py

Extra Resources

About

Display upcoming Port Authority of Allegheny County bus times on a scrolling LED message board

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages