-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.py
29 lines (25 loc) · 924 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
from machine import UART
import machine
from network import WLAN
import os
import time
from config import SSID, PSK, WIFI_ENABLED
uart = UART(0, 115200)
os.dupterm(uart)
rtc = machine.RTC()
wlan = WLAN() # get current object, without changing the mode
if WIFI_ENABLED:
if machine.reset_cause() != machine.SOFT_RESET:
wlan.init(mode=WLAN.STA)
# configuration below MUST match your home router settings!!
#wlan.ifconfig(config=('192.168.1.101', '255.255.255.0', '192.168.1.1', '8.8.8.8'))
if not wlan.isconnected():
# change the line below to match your network ssid, security and password
wlan.connect(SSID, auth=(WLAN.WPA2, PSK), timeout=5000)
while not wlan.isconnected():
machine.idle() # save power while waiting
print('WLAN connection succeeded!')
print(wlan.ifconfig())
rtc.ntp_sync("pool.ntp.org")
else:
wlan.deinit()