The Curmudgeoclast

Thoughts, projects, and ramblings of Dave Astels

Thu 30 January 2020

CircuitPython Tips

Posted by dastels in software   

This is a living document that will be added to as there are more to make note of.

Configuration Data

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 security

For things that you want to keep separate for privacy and/or security reasons, place them as constant declarations in a file named Then include that file as required.

For example, could contain

PASSWORD = b'My_WIFI_Password'
TIMEZONE = 'Area/City'
AIO_USERNAME = 'my_username'
AIO_KEY = 'my_key'

For convenience

For general settings, use Do not use despite it being a compelling name. The file works the same as and will supercede if it's present on CIRCUITPY.

For example:

import adafruit_logging as logging

DEBUG = True
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



system = System(drive.make_drive(config.DEBUG))