I successfully burned latest hex. I then started testing with Thonny. But now have serious problem with time() function.
My code uses WDT, reads an ADS1115 and sends mqtt data in intervals. This works perfect when starting main from Thonny IDE. But after disconnecting und reconnecting USB Port, I found that time is not updating. Here is a small testcode without mqtt and other overhead. Starting this code from IDE, if-clause enters correctly, but disconnecting und reconnecting usb, if-clause never gets True!
Is this a firmware bug, or maybe a problem with usb power?.....
Would be fine to get some help on this!
Code: Select all
from utime import time, sleep
from machine import Pin, Signal, PWM, ADC, I2C, SPI, WDT, reset
import network
wdtfeedtick=3
wdt=WDT(timeout=20000)
wdt.feed()
led = Pin(8, Pin.OUT)
led.value(1)
sleep(3)
led.value(0)
def main():
wdt.feed()
# print("LAN aktivieren")
# lan=network.LAN()
# lan.active(True)
# sleep(3)
# print(lan.ifconfig())
wdtfeedevent=time()+wdtfeedtick
print(wdtfeedevent)
while True:
led.value(0)
sleep(.15)
if time() > wdtfeedevent:
led.value(1)
wdtfeedevent= time()+wdtfeedtick
print("wdt.feed")
sleep(1)
wdt.feed()
led.value(0)
led.value(1)
sleep(.15)
print(time())
if __name__ == '__main__':
#Catch exceptions,stop program if interrupted accidentally in the 'try'
main()