-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.py
41 lines (29 loc) · 920 Bytes
/
boot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#############################################
# Provide your Wifi connection details here #
#############################################
WIFI_SSID = "Claro140"
WIFI_PASSWORD = "Magivi0917"
#############################################
import network
from time import sleep
from machine import Pin
import ntptime
sleep(1) # Without this, the USB handshake seems to break this script and then fail sometimes.
led = Pin("LED", Pin.OUT, value=1)
wlan = None
while not wlan or wlan.status() != 3:
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(WIFI_SSID, WIFI_PASSWORD)
# Blink LED slowly until the Wifi is connected.
while True:
print(wlan)
led.toggle()
sleep(0.2)
if wlan.status() in [-1, -2, 3]:
break
# Set the RTC to the current time
ntptime.settime()
# Solid LED means we're connected and ready to go
led.on()
print(wlan)