1
1
Fork 0
oled-thermometer/ConnectWiFi.py

36 lines
791 B
Python

def connect():
import network
from time import sleep_ms
ssid = "-Netzlein-"
password = "Lau5Buam!"
#ssid = "Phaser"
#password = "toolbelt555"
print("Connecting to WiFi")
station = network.WLAN(network.STA_IF)
if station.isconnected() == True:
print("Already connected")
return True
station.active(True)
station.connect(ssid, password) # Timeout 10 Seconds
while station.status() == 1:
# 1 connecting?
# 2 ???
# 3 failed?
# 5 connected?
sleep_ms(500)
print("Connection status")
print(station.status())
if station.isconnected():
print("Connection successful")
print(station.ifconfig())
return True
else:
return False