import network
import secrets
from utime import sleep, ticks_ms, ticks_diff
from secrets import secrets

print('Connecting to WiFi Network Name:', secrets['ssid'])
wlan = network.WLAN(network.STA_IF)
wlan.active(True)

start = ticks_ms() # start a millisecond counter

if not wlan.isconnected():
    wlan.connect(secrets['ssid'], secrets['password'])
    print("Waiting for connection...")
    counter = 0
    while not wlan.isconnected():
        sleep(1)
        print(counter, '.', sep='', end='', )
        counter += 1

delta = ticks_diff(ticks_ms(), start)
print("Connect Time:", delta, 'milliseconds')
print('IP Address:', wlan.ifconfig()[0])
