wlan.scan() errno 12 ENOMEM
I'm trying to run the wlan example in the PyCom documentation, the one where you scan for nearby networks and connect to one using this code:
nets = wlan.scan()
for net in nets:
if net.ssid == 'mywifi':
wlan.connect(net.ssid, auth=(net.sec, 'mywifikey'), timeout=5000)
while not wlan.isconnected():
machine.idle() # save power while waiting
print('WLAN connection succeeded!')
I'm using the ESP32 devkitC. My problem happens on that very first line. When I try running the command "nets = wlan.scan()" I get the following error:
OSError: [Errno 12] ENOMEM
I get this error both running the command in realtime REPL and also when loading the command into main.py on the board. From what I've read this error has to do with the board running out of memory. I checked how much memory is available:
And it said 487Kb. Is that not enough memory to do a wifi AP scan? It seems like there's something basic missing here.
robert-hh last edited by
@dhblumenfeld1989 This cannot be the full script. At least a two lines are missing upfront, like:
from network import WLAN wlan = WLAN(mode=WLAN.STA)
And as a side note: The flash size you get with uos.getfree() is not relevant for memory errors. These are caused by RAM shortage. The size of free RAM is told by gc.mem_free().
And for all people trying to help it is useful to know the firmware version, which can be obtained by uos.uname().