Software Config

With the hardware and code tested, let’s now configure the system for your personal needs. You probably have a short list of bus stops and routes that are particularly relevant from your house, office or hackerspace.

The NextBus servers use a series of special “tags” (unique identifier strings) for naming transit agencies, routes and stops. The script (in the Adafruit-NextBus directory) helps uncover the correct tags and outputs them in a format that’s easily copied into other scripts for display.


Since it’s used just a few times for setup, isn’t very glamorous to look at…simply text-based with numeric prompts. The lists it displays are sometimes long, so it’s best run from a terminal with scroll-back capability.

You’ll be prompted for a transit agency, route numer, direction and stop. The script then spits out a line of text similar to this:

  ( 'actransit', '210', '0702640', 'To Ohlone College' ),

Copy and paste the resulting line (in parenthesis) into the script. You’ll see there’s a list of routes near the top of the program:

stops = [
  ( 'actransit', '210', '0702640', 'Ohlone College' ),
  ( 'actransit', '232', '0704440', 'Fremont BART'   ),
  ( 'actransit', '210', '0702630', 'Union Landing'  ),
  ( 'actransit', '232', '0704430', 'NewPark Mall'   ) ]

Run again for each stop and route you want arrival times for, copying the output into this list.

The fourth element on each line can be edited for brevity, to use less space on the LED matrix. For example, ‘To Ohlone College’ could be shortened to ‘Ohlone College’ or even just ‘College’ if that’s sufficiently descriptive for your needs. The other elements on the line should NOT be edited though…the NextBus server expects these exactly as-is.

Below the route list you’ll see some other configurable settings…colors, number of predictions to show, etc. Comments accomanying each item explain their purpose. You might want to set a value (in minutes) for minTime — any arrivals sooner than this simply aren’t displayed — to discourage impossible or unsafe rushing for a bus. Recall the story about bus-seekers getting hit in traffic…better to wait for the next one than run across the road to make a connection.

Once configured, test it out by running the script. Initially all lines will show “No Prediction,” but one by one they should start appearing as server queries are made.

“No Prediction” is also shown when route data isn’t available — either a network error, or simply that the route isn’t running at this time, perhaps late at night or on weekends, depending on your location.


WIth the script now configured for our routes, let’s set it up to start automatically when the system boots.

Edit the file /etc/rc.local:

sudo vi /etc/rc.local

(Substitute editor of choice instead of vi)

Insert this line before the final “exit 0” line:

python /home/pi/Adafruit-NextBus/ &

Change the path if the script is located somewhere else.

Notice that you don’t need “sudo” at the start of this line…commands in rc.local are already run as root.

Reboot to confirm that everything works and starts up automatically, and the halt button (if installed) does its job.

Once it’s all configured and tested to your liking, you can put the hardware on a shelf or design a case or bracket to hold everything on the wall. This is the “arts and crafts” part of the project…every installation is different, so we don’t have a specific design to recommend…you’ll need to come up with something that meets your personal aesthetic tastes and available tools and crafting skills.

Last updated on May 04, 2015 Published on Mar 01, 2015