-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot.py
More file actions
56 lines (42 loc) · 1.01 KB
/
boot.py
File metadata and controls
56 lines (42 loc) · 1.01 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Complete project details at https://RandomNerdTutorials.com
try:
import usocket as socket
except:
import socket
from machine import Pin
import network
import time
import creds
import gc
gc.collect()
#### BLINK FUNCTION CONTROLS #####
BLUE_WIFI_LED = Pin(2, Pin.OUT)
BOARD_ADDRESS = "Not Initiated"
def blink(number, delay=300):
while number > 0:
BLUE_WIFI_LED.off()
time.sleep_ms(delay)
BLUE_WIFI_LED.on()
time.sleep_ms(delay)
number -= 1
#### MAIN ####
def boot():
SSID = creds.SSID
PASSWORD = creds.PASSWORD
station = network.WLAN(network.STA_IF)
station.active(True)
station.connect(SSID, PASSWORD)
while station.isconnected() == False:
pass
print('Connection successful')
BOARD_ADDRESS = station.ifconfig()[0]
print("Board Address: " + BOARD_ADDRESS)
time.sleep(5)
# blink last number of ip
ip_final = int(BOARD_ADDRESS.split(".")[-1]) + 1
blink(ip_final, delay=450)
print("Boot Done")
# delay for setup
time.sleep(4)
if __name__ == "__main__":
boot()