Looks like rtc is included in one of the other files
from m5stack import *
from m5ui import *
from uiflow import *
setScreenColor(0x111111)
rtc.setTime(0, 0, 0, 0, 0, 0)
OK it works. So for future reference this is what I did:
Turn on the unit (mine is an M5StickC with UIFlow 1.6.6 firmware)
press the M5 button quickly after that to enter setup mode (my screen shows <code>)
side button to get the Setup menu
M5 again to select it
Switch Mode
M5 again
side button to select APP
side button to select '..' at top
M5 to go back to previous menu
side button to select Reboot
M5 to reboot
From now on whenever you turn it on the Stick will run boot.py and then main.py in the /flash directory.
If when it's so running you attach the device to a computer via the USB cable, you can interrupt whatever it is doing by starting Thonny and hitting ctrl-F2 (Stop/Restart Backend), which will bring up the MicroPython REPL prompt. Cool.
Hello @WonkoTheSane
Hmm, did you include the line from m5stack import *?
I have UIFlow 1.6.6 firmware installed on my M5StickC Plus and use Blockly's Set screen brightness block then switched to the Python tab.
Thanks
Felix
Hello @toddkrein
you are correct, there is no RTC battery backup in M5Stack Fire.
Please note: In sleep modes time accuracy might be affected depending on the clock source used.
Please also refer to:
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html
Cheers
Felix
I'm trying to do this on the M5StickC and the "mkdir" command doesn't work. It just says "NameError: name 'mkdir' isn't defined"
Is there a different module on the M5StickC that holds these file system commands?
@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.