added watchdog and more led indication
This commit is contained in:
parent
6f84752f9d
commit
941a5fb12f
22
main.py
22
main.py
@ -1,23 +1,34 @@
|
|||||||
import network
|
import network
|
||||||
import time
|
import time
|
||||||
import config
|
import config
|
||||||
from machine import Pin, UART, Timer
|
from machine import Pin, UART, WDT
|
||||||
from umqtt.simple import MQTTClient
|
from umqtt.simple import MQTTClient
|
||||||
|
|
||||||
prefix = config.MQTT_ID + "/"
|
prefix = config.MQTT_ID + "/"
|
||||||
|
|
||||||
led = machine.Pin("LED", machine.Pin.OUT)
|
led = Pin("LED", machine.Pin.OUT)
|
||||||
led.value(1)
|
led.value(1)
|
||||||
|
time.sleep_us(200)
|
||||||
|
led.value(0)
|
||||||
|
time.sleep_us(200)
|
||||||
|
led.value(1)
|
||||||
|
time.sleep_us(200)
|
||||||
|
led.value(0)
|
||||||
|
time.sleep_us(200)
|
||||||
|
led.value(1)
|
||||||
|
|
||||||
|
wdt = WDT(timeout=30000)
|
||||||
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(config.WIFI_SSID, config.WIFI_PASS)
|
wlan.connect(config.WIFI_SSID, config.WIFI_PASS)
|
||||||
|
|
||||||
timer = Timer()
|
|
||||||
|
|
||||||
while not wlan.isconnected() and wlan.status() >= 0:
|
while not wlan.isconnected() and wlan.status() >= 0:
|
||||||
print("Waiting to connect:")
|
print("Waiting to connect:")
|
||||||
time.sleep(1)
|
led.value(1)
|
||||||
|
time.sleep_us(500)
|
||||||
|
led.value(0)
|
||||||
|
time.sleep_us(500)
|
||||||
|
|
||||||
print("Connected!")
|
print("Connected!")
|
||||||
led.value(0)
|
led.value(0)
|
||||||
@ -71,6 +82,7 @@ data = ""
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
led.value(0)
|
led.value(0)
|
||||||
|
wdt.feed()
|
||||||
|
|
||||||
if uart.any():
|
if uart.any():
|
||||||
led.value(1)
|
led.value(1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user