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)
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 Jun 25, 2021.

This page (Networking) was last updated on Mar 23, 2022.

Text editor powered by tinymce.