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

    LoPy4 WiFi not connecting in STA mode

    Scheduled Pinned Locked Moved LoPy
    9 Posts 3 Posters 64 Views 3 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.
    • E Offline
      ElectricJoe
      last edited by ElectricJoe

      I test with 8x LoPy4 modules. Just trying to simply connect to my office LAN. 50% (!) of the modules just don't want to connect!? Running the same code on all of them. Tested with 1.20.2.r3 and 1.20.2.rc11. Running out of ideas to troubleshoot. Any suggestions?

      import pycom, time
      from ubinascii import hexlify, unhexlify
      from machine import unique_id
      from network import WLAN
      
      ModuleIdent = os.uname()[1].lower()[0:4] + '_' + str(hexlify(unique_id()))[8:14]
      # results in something like 'lopy_123456'
      print('\r\n ' + ModuleIdent)
      
      pycom.heartbeat(False)
      time.sleep(2)
      pycom.rgbled(0x403000)  # yellow
      wlan = WLAN(mode=WLAN.STA)
      wlan.connect(ssid='😉😉😉', auth=(WLAN.WPA2, '😉😉😉'))
      for i in range(10):
      	time.sleep(1)
      	print('.', end='')
      	if wlan.isconnected():
      		print('\r\nWLAN connected, ip: {}'.format(wlan.ifconfig()[0]))
      		break
      print('')
      pycom.rgbled(0x000000)  # off
      time.sleep(1)
      pycom.heartbeat(True)
      
      
      L 1 Reply Last reply Reply Quote 0
      • L Offline
        livius @ElectricJoe
        last edited by livius

        @ElectricJoe
        Did you test with internal or external wifi antenna?
        Remember that wifi antenna is in different socket then lora.

        think about people first, then computers

        1 Reply Last reply Reply Quote 0
        • E Offline
          ElectricJoe
          last edited by ElectricJoe

          My understanding is by default the internal antenna is selected. But I also tested with specifically selecting WLAN.INT_ANT. Didn't make any difference.
          Running the modules in the Expansion Board 3.1.

          L 1 Reply Last reply Reply Quote 0
          • L Offline
            livius @ElectricJoe
            last edited by

            @ElectricJoe
            you should change your connection loop. Instead of range 10 which can be too short and doing sleep use idle
            you can look also at my post with chrono:
            https://forum.pycom.io/topic/2406/faster-wifi-startup/9

            think about people first, then computers

            E 1 Reply Last reply Reply Quote 0
            • E Offline
              ElectricJoe @livius
              last edited by

              @livius Thanks for that snippet. Tested even with 60 s before breaking. If it does not connect within about 3..4 s it is not connecting at all. It feels more like there is some setting screwed up internally and I cannot figure out which one. After all this error persists even after reflashing the whole shabang from scratch.

              Is there any internal settings that I can check?

              L 1 Reply Last reply Reply Quote 0
              • L Offline
                livius @ElectricJoe
                last edited by

                @ElectricJoe
                try with external antenna to see if working at all
                maybe you have some damage in internall antenna connection

                think about people first, then computers

                E 1 Reply Last reply Reply Quote 0
                • E Offline
                  ElectricJoe @livius
                  last edited by ElectricJoe

                  @livius Hmm, don't have an external antenna at hand. It works in AP mode: I can connect to the typical 192.168.4.1 address.

                  from ubinascii import hexlify
                  from machine import unique_id
                  from network import WLAN
                  wlan = WLAN()
                  wlan.init(mode=WLAN.AP, ssid=os.uname()[1].lower()[0:4] 
                      + '_' + str(hexlify(unique_id()))[8:14])
                  

                  But if I configure it in STA mode, it does not connect. Running the very same code on a different LoPy4 works fine.

                  import time
                  from network import WLAN
                  wlan = WLAN(mode=WLAN.STA)
                  wlan.connect(ssid='ssid', auth=(WLAN.WPA2, 'pwd'))
                  time.sleep(10)
                  print(wlan.isconnected(), wlan.ifconfig())
                  

                  So this indicates it is not a hardware issue. There must be something hidden in the software depths.

                  J 1 Reply Last reply Reply Quote 0
                  • J Offline
                    jcaron @ElectricJoe
                    last edited by

                    @ElectricJoe does your DHCP pool have enough available IP addresses? Home routers sometimes have ridiculously small pools by default.

                    Do you use the same or different credentials? If using the same, is there anything network-side that could limit the number of simultaneous connections with the same credentials?

                    E 1 Reply Last reply Reply Quote 2
                    • E Offline
                      ElectricJoe @jcaron
                      last edited by

                      @jcaron Did some further testing into that direction. In the end I got a separate wlan router (completely under my control, with enough ip addresses available) and had modules connect in STA mode to it. And all of them connected. Thanks for the hint.

                      1 Reply Last reply Reply Quote 2

                      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