Following good code security practices, network name and security credentials should not be "hardcoded" into CircuitPython programs. Rather they are placed in Python environment variables.
As there is no operating system used on most CircuitPython devices, the values are placed in a separate file named settings.toml.
Using settings.toml replaces using secrets.py in modern CircuitPython code.
For those platforms presenting as a thumb drive (most microcontrollers), the file is placed in the root directory of the CIRCUITPY drive.
For microcontrollers not presenting as a thumb drive, the file should be uploaded along with the code and libraries using a compatible tool, such as the CircuitPython Web Workflow Code Editor (see below).
Putting Your Networking Settings in settings.toml
There is a handy guide page for how to set up a settings.toml file for CircuitPython networking:
Defining the values for CIRCUITPY_WIFI_SSID
and CIRCUITPY_WIFI_PASSWORD
provide an automatic way for the network name and password to be used in CircuitPython programs.
It is also possible to store the values in settings.toml and not have them used automatically by CircuitPython. You can still use settings.toml to store your credentials, say in WIFI_SSID
and WIFI_PASSWORD
, then use those values in your own code.
Adafruit Web Workflow
Adafruit Web Workflow is an in-browser code editor and environment for CircuitPython using WiFi connections. See the following guide for setup and use of Web Workflow.
Text editor powered by tinymce.