Das selbe gilt für den ReStart nach dem Erwecken aus dem DeepSleep Modus.
Code: Alles auswählen
def connect():
import network, ntptime
import wlanscan
from time import sleep_ms
netscan = wlanscan.WLANscan()
ssidlist = netscan.ssid()
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
print('Searching for Network...')
sta_if.active(True)
for net in ssidlist:
#print(net)
if net == 'SSID-1':
sta_if.connect('SSID-1', 'Password')
while not sta_if.isconnected():
print('connecting ...')
sleep_ms(500)
break
if str(net) == 'SSID-2':
sta_if.connect('SSID-2', 'Password')
while not sta_if.isconnected():
print('connecting ...')
sleep_ms(500)
break
if str(net) == 'SSID-3':
sta_if.connect('SSID-3', 'Password')
while not sta_if.isconnected():
print('connecting ...')
sleep_ms(500)
break
if not sta_if.isconnected():
print('Kein bekanntes Netzwerk gefunden')
else:
print('Network connected:', sta_if.ifconfig())
sleep_ms(1000)
ntptime.settime()
sleep_ms(1000)
def no_debug():
import esp
esp.osdebug(None)
def disconnect():
import network
sta_if = network.WLAN(network.STA_IF)
sta_if.disconnect()
no_debug()
connect()