From 941a5fb12fa59fbe75d1ee4fa680e8a5d4e2f810 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sat, 17 Sep 2022 21:51:45 +0200 Subject: [PATCH] added watchdog and more led indication --- main.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 1d97643..3ac25f5 100644 --- a/main.py +++ b/main.py @@ -1,23 +1,34 @@ import network import time import config -from machine import Pin, UART, Timer +from machine import Pin, UART, WDT from umqtt.simple import MQTTClient prefix = config.MQTT_ID + "/" -led = machine.Pin("LED", machine.Pin.OUT) +led = Pin("LED", machine.Pin.OUT) 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.active(True) wlan.connect(config.WIFI_SSID, config.WIFI_PASS) -timer = Timer() - while not wlan.isconnected() and wlan.status() >= 0: print("Waiting to connect:") - time.sleep(1) + led.value(1) + time.sleep_us(500) + led.value(0) + time.sleep_us(500) print("Connected!") led.value(0) @@ -71,6 +82,7 @@ data = "" while True: led.value(0) + wdt.feed() if uart.any(): led.value(1)