Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (37 sloc) 1.46 KB
import network
import utime
def wifi_connect(essid, password):
# Connect to the wifi. Based on the example in the micropython
# documentation.
wlan = network.WLAN(network.STA_IF)
if not wlan.isconnected():
print('connecting to network ' + essid + '...')
wlan.connect(essid, password)
# connect() appears to be async - waiting for it to complete
while not wlan.isconnected():
print('waiting for connection...')
print('checking connection...')
print('Wifi connect successful, network config: %s' % repr(wlan.ifconfig()))
# Note that connection info is stored in non-volatile memory. If
# you are connected to the wrong network, do an explicity disconnect()
# and then reconnect.
print('Wifi already connected, network config: %s' % repr(wlan.ifconfig()))
def wifi_disconnect():
# Disconnect from the current network. You may have to
# do this explicitly if you switch networks, as the params are stored
# in non-volatile memory.
wlan = network.WLAN(network.STA_IF)
if wlan.isconnected():
print("Wifi not connected.")
def disable_wifi_ap():
# Disable the built-in access point.
wlan = network.WLAN(network.AP_IF)
print('Disabled access point, network status is %s' %
You can’t perform that action at this time.