import wifi
networks = []
for network in
networks = sorted(networks, key=lambda net: net.rssi, reverse=True)
for network in networks:
    print("ssid:",network.ssid, "rssi:",network.rssi)

What the heck is settings.toml?

re. Using and getting Environment Variables

settings.toml a config file that lives next to your and is used to store WiFi credentials and other global settings. It is also used (invisibly) by many Adafruit libraries that do WiFi. You can use it (as in the examples above) without those libraries. The settings names used by CircuitPython are documented in CircuitPython Web Workflow.

Using settings.toml replaces using in modern CircuitPython code.

Note: You can use any variable names for your WiFI credentials (a common pair is WIFI_SSID and WIFI_PASSWORD), but if you use the CIRCUITPY_WIFI_* names that will also start up the Web Workflow

You use it like this for basic WiFi connectivity:

# settings.toml
CIRCUITPY_WIFI_PASSWORD = "mysecretpassword"

import os, wifi
print("my IP addr:",

See the page below as an example of using settings.toml:

Adafruit ESP32-S2 Feather
By Kattni Rembor
View Guide

The examples below still use the old rather than the modern settings.toml used above.

import time
import wifi
import ipaddress
from secrets import secrets
ip_to_ping = ""['ssid'],password=secrets['password'])

print("my IP addr:",
print("pinging ",ip_to_ping)
ip1 = ipaddress.ip_address(ip_to_ping)
while True:
import time
import wifi
import socketpool
import ssl
import adafruit_requests
from secrets import secrets['ssid'],password=secrets['password'])
print("my IP addr:",
pool = socketpool.SocketPool(
session = adafruit_requests.Session(pool, ssl.create_default_context())
while True:
    response = session.get("")
    data = response.json()

What the heck is

It's a config file that lives next to your and is used (invisibly) by many Adafruit WiFi libraries. You can use it too (as in the examples above) without those libraries

It looks like this for basic WiFi connectivity:

secrets = {
  "ssid": "Pretty Fly for a WiFi",
  "password": "donthackme123"
from secrets import secrets
print("your WiFi password is:", secrets['password'])

Other field/value pairs may be in for using passwords to Adafruit IO or other applications, to denote a time zone, etc.

This guide was first published on Apr 02, 2022. It was last updated on May 15, 2024.

This page (Networking) was last updated on May 15, 2024.

Text editor powered by tinymce.