secrets.py on the CIRCUITPY drive holds your WiFi network credentials and other info. This file can be created or edited with any simple text editor you prefer. It resides in the root directory of the CIRCUITPY drive, not inside a folder.

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

If not, it should resemble what’s below, with the ssid and password lines. The corresponding values for these (after the colon) is in single-quotes.

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).

Latitude and longitude are optional but recommended. The clock can do IP geolocation (estimating your location using IP address), but having it here is more accurate and avoids another server query on startup. These values are floating-point numbers (in degrees and decimal fractions thereof) and should not be in quotes. For latitude, positive values are north, negative is south. For longitude, negative is west, positive is east.

secrets = {
    'ssid'      : 'WiFi-Network-Name',
    'password'  : 'WiFi-Network-Password',
    'latitude'  : 32.71193,
    'longitude' : -117.16072
}

You can easily get your decimal latitude and longitude from Google Maps. Zoom in on a location and right-click on the map. Information there includes latitude and longitude in exactly the format we need…click the coordinates to copy them to the clipboard, then paste into the secrets file and reformat the text as shown above.

The code will relaunch any time there’s a change on the CIRCUITPY drive…so, after editing secrets.py, the clock should start up on its own and you’ll see a splash screen after a few seconds.

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

This guide was first published on Sep 23, 2020. It was last updated on Sep 23, 2020.

This page (Configure Network and Location) was last updated on Sep 16, 2020.

Text editor powered by tinymce.