secrets.py 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 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.711956,
    'longitude' : -117.160838
}

You can easily get your decimal latitude and longitude from Google Maps. Zoom in on your location and click on the map. The nearest address (and street view if available) will pop up at the bottom of the map, the information there includes latitude and longitude in exactly the format we need…you can just copy and paste those into the secrets file. Update: you might need to right-click the location to get the geographic coordinates now.

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 May 05, 2021.

Text editor powered by tinymce.