I would really appreciate it if someone could help me out with a quick fix here, but also I want to understand what they want me to do and why, and of course how to do something similar in future - please and thanks!
Code: Select all
import machine
import ubinascii
import network
import time
import urllib.urequest
# Network
SSID = "SSID" # Network Name
Password = "PASSWORD" # Network password
station = network.WLAN(network.STA_IF)
station.active(True)
def WiFiConnect():
# Connect
station.connect(SSID, Password)
# Wait for connection
print("connecting...")
while not station.isconnected():
print("...")
time.sleep(5)
print("Connected!\n")
WiFiConnect()
while True:
print('ip address, netmask, gateway, DNS:')
print(station.ifconfig()) # reveal the devices ip address
print('')
print('Device MAC = ', ubinascii.hexlify(machine.unique_id(),':').decode())
print('')
print('wifi interface MAC = ', ubinascii.hexlify(station.config('mac'),':').decode())
print('')
contents = urllib.urequest.urlopen("http://google.com")
contents.close()
time.sleep(10)