Intro

There are a total of four code files that make this project happen: secrets.py, calendar.py, openweather_graphics.py and code.py. Most similar are the secrets.py and calendar.py files. Their function is to hold user data that is then pulled into both openweather_graphics.py and code.py to allow everything to run smoothly.

secrets.py

If you've ever done a PyPortal project or other IoT project with CircuitPython, then the secrets.py file will be familiar to you. It allows you to store your WiFi network's SSID and password, along with other sensitive information, separately from your main program, so that you don't accidentally share your info when sharing your code.

In the case of this project, you will need your network information, as well as your OpenWeatherMaps token, Adafruit AIO information and your location, all formatted to be able to pass it to OpenWeatherMaps. By keeping your location in secrets.py, you can easily edit it without diving too deep into the main program or risk breaking anything.

# This file is where you keep secret settings, passwords, and tokens!
# If you put them in the code you risk committing that info or sharing it

secrets = {
    'ssid' : 'your-ssid-here',
    'password' : 'your-password-here',
    'openweather_token' : 'your-openweather-token-here',
    'aio_username' : "your-aio-username-here",
    'aio_key' : 'your-aio-key-here',
    'location' : 'New York, US'
}

This guide was first published on Jan 29, 2020. It was last updated on Jan 29, 2020.

This page (Code Walkthrough - secrets.py) was last updated on Dec 01, 2021.

Text editor powered by tinymce.