circuitpython: ConnectionError when attempting to connect to a known SSID (6.2.0b1)
wifi.radio.connect() call seems to improperly raise a ConnectionError: No network with that ssid
even when the SSID is found by a WiFi scan.
Platform: Adafruit CircuitPython 6.2.0-beta.1 on 2021-01-27; Adafruit MagTag with ESP32S2
Code
import ipaddress
import ssl
import wifi
import socketpool
# Get wifi details and more from a secrets.py file
try:
from secrets import secrets
except ImportError:
print("WiFi secrets are kept in secrets.py, please add them there!")
raise
print("ESP32-S2 WebClient Test")
print("My MAC addr:", [hex(i) for i in wifi.radio.mac_address])
print("Available WiFi networks:")
for network in wifi.radio.start_scanning_networks():
print("\t%s\t\tRSSI: %d\tChannel: %d" % (str(network.ssid, "utf-8"),
network.rssi, network.channel))
wifi.radio.stop_scanning_networks()
print("Connecting to %s"%secrets["ssid"])
wifi.radio.connect(secrets["ssid"], secrets["password"])
print("Connected to %s!"%secrets["ssid"])
print("My IP address is", wifi.radio.ipv4_address)
Output:
code.py output:
ESP32-S2 WebClient Test
My MAC addr: ['0x7c', '0xdf', '0xa1', '0x5', '0xfa', '0x26']
Available WiFi networks:
NETWORKNAME RSSI: -79 Channel: 1
....
Connecting to NETWORKNAME
Traceback (most recent call last):
File "code.py", line 25, in <module>
ConnectionError: No network with that ssid
Code done running.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (5 by maintainers)
Closing, given the age of this. Please reopen with an updated example if you still see this.
So, I just have run into this issue on a MagTag, on both the latest CircuitPython 7 release, but also on the 8 Beta. Interestingly, this seems to only happen when the MagTag is plugged in via USB into my laptop. It’s fine if it’s running off the battery. Also, it works fine using the same USB cable on a powerbank.
So ultimately, a noisy power supply or a noisy ground level might just be to blame here…