Created
December 13, 2019 15:18
-
-
Save agentzex/a981acc8a88975cecac0587d206f42ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.urequest | |
import time | |
import network | |
time.sleep(3) | |
print("\n\n\n***********\n") | |
wlan = network.WLAN(network.STA_IF) | |
wlan.active(True) | |
if wlan.isconnected(): | |
print("wlan connected at startup") | |
else: | |
print("wlan not connected, trying to connect") | |
wlan.connect("mywifi", "mypassword") | |
retries = 0 | |
while not wlan.isconnected(): | |
retries = retries + 1 | |
if retries < 10000: | |
print("cant connect to wifi") | |
machine.idle() | |
else: | |
break | |
print("Connected after " + str(retries) + " tries") | |
ret = urllib.urequest.urlopen("http://192.168.1.100/hello") | |
time.sleep(3) | |
ret = urllib.urequest.urlopen("http://192.168.1.100/hello") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment