fix wifi issue, also want flashing light while wifi is connected. Fixed it.
This commit is contained in:
parent
889ddee324
commit
328302d8ee
19
main.py
19
main.py
@ -4,13 +4,10 @@ import network
|
|||||||
import urequests as requests
|
import urequests as requests
|
||||||
from secrets import secrets
|
from secrets import secrets
|
||||||
|
|
||||||
# Initialize pins
|
# Initialize pins (LED light onboard)
|
||||||
contactorLights = Pin(18, Pin.OUT)
|
|
||||||
led = Pin("LED", Pin.OUT)
|
led = Pin("LED", Pin.OUT)
|
||||||
|
|
||||||
# Initial state
|
# Initial state
|
||||||
led.low()
|
led.low()
|
||||||
contactorLights.low()
|
|
||||||
|
|
||||||
# Network connection
|
# Network connection
|
||||||
def connect_wifi():
|
def connect_wifi():
|
||||||
@ -45,10 +42,18 @@ wifi = connect_wifi()
|
|||||||
# Connection monitoring loop
|
# Connection monitoring loop
|
||||||
while True:
|
while True:
|
||||||
if not wifi or not wifi.isconnected():
|
if not wifi or not wifi.isconnected():
|
||||||
|
# Fast blink when disconnected
|
||||||
led.on()
|
led.on()
|
||||||
time.sleep(0.5)
|
time.sleep(0.2)
|
||||||
led.off()
|
led.off()
|
||||||
time.sleep(0.5)
|
time.sleep(0.2)
|
||||||
# Try to reconnect
|
# Try to reconnect
|
||||||
wifi = connect_wifi()
|
wifi = connect_wifi()
|
||||||
time.sleep(1)
|
else:
|
||||||
|
# Slow blink when connected
|
||||||
|
led.on()
|
||||||
|
time.sleep(1)
|
||||||
|
led.off()
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
time.sleep(0.1)
|
||||||
Loading…
x
Reference in New Issue
Block a user