Tue, 21 Mar 2023 11:45:08 +0100
MicroPython
- Changed the 'fileSystemInfo()' method such, that it finds mounted file systems as well.
9836 | 1 | try: |
2 | import secrets | |
3 | ||
9890
66a6d3f131cc
Changed the MCU script to a pythonic naming.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9836
diff
changeset
|
4 | def connect_wifi(): |
9836 | 5 | import network |
6 | from time import sleep | |
7 | ||
8 | print("Connecting WiFi to '{0}' ...".format(secrets.WIFI_SSID)) | |
9 | wifi = network.WLAN(network.STA_IF) | |
10 | wifi.active(False) | |
11 | wifi.active(True) | |
12 | wifi.connect(secrets.WIFI_SSID, secrets.WIFI_KEY if secrets.WIFI_KEY else None) | |
13 | max_wait = 140 | |
14 | while max_wait: | |
15 | if wifi.status() < 0 or wifi.status() >= 3: | |
16 | break | |
17 | max_wait -= 1 | |
18 | sleep(0.1) | |
19 | if wifi.isconnected(): | |
20 | print("WiFi connected:", wifi.ifconfig()) | |
21 | else: | |
22 | print("WiFi connection failed") | |
23 | ||
9890
66a6d3f131cc
Changed the MCU script to a pythonic naming.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9836
diff
changeset
|
24 | connect_wifi() |
9836 | 25 | except ImportError: |
26 | print("WiFi secrets are kept in 'secrets.py', please add them there!") |