LoPy4 WiFi not connecting in STA mode
-
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)
-
@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.
-
@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?
-
@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.
-
@ElectricJoe
try with external antenna to see if working at all
maybe you have some damage in internall antenna connection
-
@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?
-
@ElectricJoe
you should change your connection loop. Instead of range 10 which can be too short and doingsleep
use idle
you can look also at my post with chrono:
https://forum.pycom.io/topic/2406/faster-wifi-startup/9
-
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.
-
@ElectricJoe
Did you test with internal or external wifi antenna?
Remember that wifi antenna is in different socket then lora.