@shariq I have the code below in main.py, which sets up the device for connecting to my router with a fixed IP, which you then can use to access the device.
WIFI_IP = "aa.bb.cc.ss"
ROUTER_IP = "aa.bb.cc.rr")
WIFI_SSID = "your AP SSID"
WIFI_PASS = "your AP Password"
def do_connect():
import network
import time
wlan = network.WLAN(mode=network.WLAN.STA) # create station interface
if not wlan.isconnected(): # check if the station is connected to an AP
wlan.ifconfig(config=(WIFI_IP, "255.255.255.0", ROUTER_IP, ROUTER_IP))
wlan.connect(ssid=WIFI_SSID, auth=(network.WLAN.WPA2, WIFI_PASSWD))
for _ in range(100):
if wlan.isconnected(): # check if the station is connected to an AP
break
print('.', end='')
time.sleep_ms(200)
else:
print("Connect attempt timed out\n")
return
print('\nnetwork config:', wlan.ifconfig())
do_connect()