wifiCfg

Use the API in the wifiCfg module to configure the device Wi-Fi connection.

wifiCfg.autoConnect(lcdShow=True)

  • Automatically connect to the saved WiFi, the screen displays the connection UI

wifiCfg.doConnect(ssid, pwd)

  • Connect to designated WiFi

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

  • Connect to the specified WiFi and specify the connection timeout period

wifiCfg.reconnect()

  • WiFi reconnect

wifiCfg.wlan_sta.isconnected()

  • Is it connected

wifiCfg.wlan_sta.ifconfig()

  • View connection information

Example


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