Lookup here …
How to connect to the Internet
An Internet connection via WiFi can easily be established by for example storing a boot.py file with the following content on the device:
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
#import webrepl
#webrepl.start()
def do_connect():
import network
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
print('connecting to network...')
sta_if.active(True)
sta_if.connect('HuSo_WiFi', 'HuSo_Password')
while not sta_if.isconnected():
pass
print('network config:', sta_if.ifconfig())
do_connect()
The device will establish an Internet Connection as soon as it powers up and the WiFi network is available.