best practice for wifi connection
-
Hello there,
My project has a wifi connection and the set up looks like this:
My question:- how to prioritize networks? If two network is avaible, prefer one then the other. In this setup it goes the first in the ABC.
- I added a block if no known network found, then sleep for minute and search again. But somehow always goes to the else part. Can you hint why?
- Is there a tool to debug the micropython code? It would be helpful sometimes
- do you have any other tips? Thanks in advance! :)
while not wlan.isconnected(): for net in nets: if net.ssid == '******': print(str(net.ssid)+" found!") lcd.putstr(str(net.ssid)+" found!") wlan.connect("******", auth=(WLAN.WPA2, "*****"), timeout=5000) elif net.ssid == '***': print(str(net.ssid)+" found!") lcd.putstr(str(net.ssid)+" found!") wlan.connect("***", auth=(WLAN.WPA2, "*******"), timeout=5000) elif net.ssid == '******': print(str(net.ssid)+" found!") lcd.putstr(str(net.ssid)+" found!") wlan.connect("******", auth=(WLAN.WPA2, "*********"), timeout=5000) else: lcd.clear() lcd.putstr("No network, sleeping for 1 min") lcd.move_to(0, 1) lcd.backlight_off() machine.deepsleep(60000) machine.reset()