9889:49728322ffb4 | 9890:66a6d3f131cc |
---|---|
1 try: | 1 try: |
2 import secrets | 2 import secrets |
3 | 3 |
4 def connectWiFi(): | 4 def connect_wifi(): |
5 import network | 5 import network |
6 from time import sleep | 6 from time import sleep |
7 | 7 |
8 print("Connecting WiFi to '{0}' ...".format(secrets.WIFI_SSID)) | 8 print("Connecting WiFi to '{0}' ...".format(secrets.WIFI_SSID)) |
9 wifi = network.WLAN(network.STA_IF) | 9 wifi = network.WLAN(network.STA_IF) |
19 if wifi.isconnected(): | 19 if wifi.isconnected(): |
20 print("WiFi connected:", wifi.ifconfig()) | 20 print("WiFi connected:", wifi.ifconfig()) |
21 else: | 21 else: |
22 print("WiFi connection failed") | 22 print("WiFi connection failed") |
23 | 23 |
24 connectWiFi() | 24 connect_wifi() |
25 except ImportError: | 25 except ImportError: |
26 print("WiFi secrets are kept in 'secrets.py', please add them there!") | 26 print("WiFi secrets are kept in 'secrets.py', please add them there!") |