This is a living document that will be added to as there are more to make note of.
Sometimes you have data that controls your app which you want to keep out of the code itself. This could be because you don't want to publish it with the code (things like keys and passwords) or you want to be able to change it in one place rather than digging through code for each occurance.
For things that you want to keep separate for privacy and/or security reasons, place them as constant declarations in a file named
secrets.py. Then include that file as required.
secrets.py could contain
SSID = b'My_SSID' PASSWORD = b'My_WIFI_Password' TIMEZONE = 'Area/City' AIO_USERNAME = 'my_username' AIO_KEY = 'my_key'
For general settings, use
config.py. Do not use
settings.py despite it being a compelling name. The file
settings.py works the same as
boot.py and will supercede
boot.py if it's present on
import adafruit_logging as logging DEBUG = True LOGGING_LEVEL = logging.DEBUG BASE_SPEED = 0.5 LOG_FILE = '/log.txt'
In either case this file gets imported as required and its valued accessed:
import secrets ... self._esp.connect_AP(secrets.SSID, secrets.PASSWORD)
import config ... logger.setLevel(config.LOGGING_LEVEL) system = System(drive.make_drive(config.DEBUG))