holds your WiFi network credentials and other info. This file can be created or edited with any simple text editor you prefer.

If you already have this file on your MagTag from prior projects…great!

If not, it should resemble what’s below, with the ssid and password lines, edited to match your WiFi network credentials. The corresponding values for these (after the colon) are in single-quotes. Other projects may add their own special lines.

The format of this file is super persnickety, every space and comma counts! If creating it for the first time, best to copy-and-paste the text below exactly, then change any items of interest (preserving quotation marks and such).

secrets = {
    'ssid'     : 'WiFi-Network-Name',
    'password' : 'WiFi-Network-Password'

The code will relaunch any time there’s a change on the CIRCUITPY drive…so, after editing, the clock should start up on its own and within a minute or so you’ll see some initial bus predictions (we’ll configure the routes and stops in a moment).

If the clock does NOT start up: most likely the WiFi credentials are incorrect, or something is wrong with the file syntax…make sure every quote, comma and colon is there and in the right place.

Configuring Stops and Routes

The clock can display predictions for up to four transit stop/route combos. So…for example…there are two principal bus lines that run nearest my house, with stops on the near and far sides of the street as the buses run in alternate directions…four permutations in total.

This is the part of the project that requires use of Python from the command line.

Included in the project folder is a file called This file does not go on the microcontroller board…you use this one on your regular computer to look up information about transit agencies and stops. Once configured, you won’t need it anymore, unless you want to change the settings later.

From the command line:


(You might be able to type just “python” if “python3” throws an error.)

This is an old-school text application that will guide you through a list of transit agencies, route numbers, directions and stops. Just type the number corresponding to the item of interest (sometimes the lists are long, so it helps to have a terminal program with scroll-back capability):

After making all your selections, the program then spits out a message like the following:

    ('lametro', '79', '2549', 'Arcadia Station'),

That second line…the part in parenthesis…you’ll want to copy and paste that into a specific part of the file on the CIRCUITPY drive…

Look for a block of code resembling the following, starting around line 28 or so:

    ('lametro', '79', '11086', 'Downtown'),
    ('lametro', '79', '2549', 'Arcadia'),
    ('lametro', '260', '11086', 'Altadena'),
    ('lametro', '260', '2549', 'Artesia')

Replace one of those lines with the line you copied from the routefinder output, then save the file.

Repeat running for each additional route and stop you want (up to a maximum of four), copying each into Any extra lines can be deleted if using fewer than four.

One extra step you can optionally perform: space on the MagTag display is limited, so it’s helpful to abbreviate each route’s description. In the example above, NextBus described one route/direction as “Arcadia Station” … but, since this is the only route making any mention of Arcadia, the example code abbreviated this to “Arcadia” (“Station” was manually removed). The others were all shortened as well (e.g. “Downtown LA” is just “Downtown” in example).

This guide was first published on Nov 25, 2020. It was last updated on Nov 25, 2020.

This page (Configure Network and Transit Selections) was last updated on Dec 23, 2020.

Text editor powered by tinymce.