Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    wlan.scan() errno 12 ENOMEM

    Scheduled Pinned Locked Moved MicroPython
    wifimemoryerroresp32micropython
    2 Posts 2 Posters 1.2k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      dhblumenfeld1989
      last edited by

      Hi everyone,

      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':
      print('Network found!')
      wlan.connect(net.ssid, auth=(net.sec, 'mywifikey'), timeout=5000)
      while not wlan.isconnected():
      machine.idle() # save power while waiting
      print('WLAN connection succeeded!')
      break

      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:

      os.getfree('/flash')

      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-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @dhblumenfeld1989
        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().

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • 1 / 1
        • First post
          Last post

        Pycom on Twitter

        Pycom