wifiCfg

Use APIs from the wifiCfg module to configure device WiFi connection.

wifiCfg.autoConnect(lcdShow=True)

  • Automatically connect to the saved WiFi networks, displaying connection UI on the screen.

wifiCfg.doConnect(ssid, pwd)

  • Connect to the specified WiFi network.

wifiCfg.connect(ssid, pwd, timeout, block=False)

  • Connect to the specified WiFi network with a specified connection timeout.

wifiCfg.reconnect()

  • Reconnect WiFi.

wifiCfg.wlan_sta.isconnected()

  • Check if already connected.

wifiCfg.wlan_sta.ifconfig()

  • View connection information.

Example Program


import wifiCfg
import time

print("start connect")
wifiCfg.doConnect('ssid', 'password')

while True:
    if not (wifiCfg.wlan_sta.isconnected()):
        print("try reconnect")
        wifiCfg.reconnect()
    print("get ifconfig")
    print(wifiCfg.wlan_sta.ifconfig())
    #('192.168.1.xx', '255.255.255.0', '192.168.1.1', '192.168.1.1')
    wait(5)
On This Page