@m5stack I will share pseudo-codes of the current implementation, which is stable so far:
CycleTimer = Timer(-1) def main(): # init and connect mqtt client doCycle() def doCycle(): global CycleTimer # send stuff from mqtt # NOTE: do not use machine.lightsleep() as publish() is NOT synchronous # lightsleep() will block data from being sent CycleTimer.init(period=5000, mode=Timer.ONE_SHOT, callback=doCycle)NOTE: this is power-intensive; calling lightsleep() will cause uiflow's mqtt client to crash quickly.