Skip to content
Discussion options

You must be logged in to vote

To connect to WiFi use something like this (changing network name and password):

def do_connect():
    import network
    sta_if = network.WLAN(network.STA_IF)
    ap = network.WLAN(network.AP_IF) # create access-point interface
    ap.active(False)         # deactivate the interface
    if not sta_if.isconnected():
        print('connecting to network...')
        sta_if.active(True)
        sta_if.connect("NETWORK_NAME", "PASSWORD")
        while not sta_if.isconnected():
            pass
    print('network config:', sta_if.ifconfig())
    a = sta_if.config('mac')
    print('MAC {:02x}:{:02x}:{:02x}:{:02x}:{:02x}'.format(a[0],a[1],a[2],a[3],a[4]))

In general you don't need to worry abou…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@shorted-neuron
Comment options

Answer selected by shorted-neuron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants