<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[BUG: in Power.timerSleep() UIFlow2.0 for Core-INK]]></title><description><![CDATA[<p dir="auto">I think there is a bug in the <strong>timerSleep()</strong> function in UIFlow 2.0 for CORE-INK.<br />
<img src="/assets/uploads/files/1715000855892-0f010509-2d06-41fa-9bc3-6ed2bfd08074-image-resized.png" alt="0_1715000853459_0f010509-2d06-41fa-9bc3-6ed2bfd08074-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I assume the <strong>Power.timerSleep()</strong> function is replacing the <strong>UIFlow 1.x.. power.restart_after_seconds()</strong> which works as expected.</p>
<p dir="auto">The new function seems to only put the ESP32 in sleep mode and <em>not</em> switching off the hole board. It does work partly as it do restart the board after the given amount of seconds.<br />
As far as I have figured out it do in fact initialize the BM8365 RTC to interrupt at the given seconds but it does not (probably) set GPIO12 low to switch off the "board-power".</p>
]]></description><link>https://community.m5stack.com/topic/6426/bug-in-power-timersleep-uiflow2-0-for-core-ink</link><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Apr 2026 09:51:06 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/6426.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 06 May 2024 13:30:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to BUG: in Power.timerSleep() UIFlow2.0 for Core-INK on Tue, 14 May 2024 09:41:02 GMT]]></title><description><![CDATA[<p dir="auto">Here is a workaround for UIFLow2.0:</p>
<pre><code>import M5
import hardware
import time

# UIFlow2.0 workaround for M5.Power.timerSleep() not working properly
# on SOME CoreINK devices. On these decvices the board-power is not
# proberly turned off. However, the M5.Power.powerOff() does work
# for these devices, i.e. turning board-power properly off
 
M5.begin()
#init i2c bus with pins connected to the RTC
i2c0 = hardware.I2C(0, scl=hardware.Pin(22), sda=hardware.Pin(21), freq=400000)

##### Put your code here.
time.sleep(3)      


##### code substitution the timerSleep() function
# Set registers of the RTC. ref datasheet for BM8563 RTC for further info
# reg 0x00  always 00h
# reg 0x01  bit 2-7: always 0, bit 0: enable/disable timer int
#           0x01 = timer enabled           
reg00_01 = bytearray([0x00, 0x01])

# reg 0x0D  always 00h - clock out disabled
# reg 0x0E  bit 7: endable/disable timer, bit 0-1 timer resolution
#           10=sec  11 = min
#           0x82 = int enabled and seconds resolution
# reg 0x0F  timer value 0-255
#           0x14 = 20d = 20 sec. if reg 0x0E = 0x83 then 20 min
reg0D_0F = bytearray([0x00, 0x82, 0x14])

# i2c device address of RTC is 0x51
# Write to register address 0x00-0x01
i2c0.writeto_mem(0x51,0x00, reg00_01)

# Write to register adsress 0x0D-0x0F
i2c0.writeto_mem(0x51,0x0D, reg0D_0F)

M5.Power.powerOff()
##### end of code substitution the timerSleep() function
</code></pre>
]]></description><link>https://community.m5stack.com/post/25220</link><guid isPermaLink="true">https://community.m5stack.com/post/25220</guid><dc:creator><![CDATA[Cognitive5525]]></dc:creator><pubDate>Tue, 14 May 2024 09:41:02 GMT</pubDate></item><item><title><![CDATA[Reply to BUG: in Power.timerSleep() UIFlow2.0 for Core-INK on Mon, 13 May 2024 13:29:50 GMT]]></title><description><![CDATA[<p dir="auto">Update.<br />
After many tests I think I have pinpointed <em>where</em> it goes wrong but not exactly <em>why</em>.</p>
<p dir="auto">With the "bad" devices when driving pin 12 low the device does not turn off as expected while the "good" devices do. With the "good" devices I even get a serial monitor message saying "<em>Brown??</em>" (or sometimes partly, like "<em>Bro</em>")  which I assume is a "Brown out" message generated "deep" in Espressif's libraries. I think that make sense since the power supply is kind of "brutally" removed from the ESP when pin 12 is driven low.</p>
<p dir="auto">So basically on some "bad" M5 Core INK devices this piece of C++ code that should shut down the board by driving pin 12 low does not work:</p>
<pre><code>m5gfx::gpio_lo( pwrHoldPin );
</code></pre>
<p dir="auto">(Line #672 in PowerClass.cpp)</p>
<p dir="auto">I have also verified it in UIFlow2.0 by "manually" pulling pin 12 low:</p>
<pre><code>import M5
import time
import hardware

M5.begin()

pin12 = hardware.Pin(12, mode=hardware.Pin.OUT, pull=hardware.Pin.PULL_UP)
time.sleep(3)
pin12.off()
</code></pre>
<p dir="auto">With above UIFlow2.0 python code the "good" devices shut down completely as expected, while the "bad" ones does not.</p>
<p dir="auto">But there is more. While troubleshooting I (for other reasons) updated the <a href="http://platform.io" target="_blank" rel="noopener noreferrer nofollow ugc">platform.io</a> version from 6.3.0 to 6.6.0 (I'm using <a href="http://Platform.IO" target="_blank" rel="noopener noreferrer nofollow ugc">Platform.IO</a> with Vs-code to compile C++ code for the CoreINK) and then the "bad" devices began to work as expected i.e. they were shutting down by pulling pin 12 low. I noticed that the ESP-IDF version is 5.2.1 in <a href="http://Platform.io" target="_blank" rel="noopener noreferrer nofollow ugc">Platform.io</a> version 6.6.0 but t is version 5.1.1 in version 6.4.0 (for some reason <a href="http://Platform.io" target="_blank" rel="noopener noreferrer nofollow ugc">Platform.io</a> V 6.3.x is not listed on GitHub).</p>
]]></description><link>https://community.m5stack.com/post/25205</link><guid isPermaLink="true">https://community.m5stack.com/post/25205</guid><dc:creator><![CDATA[Cognitive5525]]></dc:creator><pubDate>Mon, 13 May 2024 13:29:50 GMT</pubDate></item><item><title><![CDATA[Reply to BUG: in Power.timerSleep() UIFlow2.0 for Core-INK on Wed, 08 May 2024 08:50:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/4037">@felmue</a> said in <a href="/post/25106">BUG: in Power.timerSleep() UIFlow2.0 for Core-INK</a>:</p>
<blockquote>
<p dir="auto">If you revert your change do the two 'bad' boards start to fail again or are they 'cured' now?</p>
</blockquote>
<p dir="auto">They start to fail again. At least some kind of consistence 😏</p>
<p dir="auto">We have 30+ Core INK running on battery as "IoT-devices". The program is written in Micropython on the UiFlow 1.x  firmware but also here some devices does not always work well with the old/current <strong>m5stack.power.restart_after_seconds(sec)</strong><br />
So I had hoped this would be better in UIFlow2.0 so we could port the program - but no.</p>
<p dir="auto">Now my dilemma is whether to stay on UIFlow 1.x or wait for M5Stack to maybe solve this issue in UIFlow2.0 (I hope you are reading this thread M5Stack😉) or to port the hole thing to C++ where I have some more freedom to fix "low-level" issues like this.</p>
]]></description><link>https://community.m5stack.com/post/25128</link><guid isPermaLink="true">https://community.m5stack.com/post/25128</guid><dc:creator><![CDATA[Cognitive5525]]></dc:creator><pubDate>Wed, 08 May 2024 08:50:09 GMT</pubDate></item><item><title><![CDATA[Reply to BUG: in Power.timerSleep() UIFlow2.0 for Core-INK on Tue, 07 May 2024 20:12:46 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/30733">@Cognitive5525</a></p>
<p dir="auto">interesting. Thanks for sharing. If you revert your change do the two 'bad' boards start to fail again or are they 'cured' now?</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/25106</link><guid isPermaLink="true">https://community.m5stack.com/post/25106</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Tue, 07 May 2024 20:12:46 GMT</pubDate></item><item><title><![CDATA[Reply to BUG: in Power.timerSleep() UIFlow2.0 for Core-INK on Tue, 07 May 2024 19:45:44 GMT]]></title><description><![CDATA[<p dir="auto">Further testing with the Arduino libraries and with the following code:</p>
<pre><code>#include "M5Unified.h"

void setup() {
    M5.begin();
    //M5.Power.powerOff();
     delay(10000);
    M5.Power.timerSleep(12);
  }

void loop() {}
</code></pre>
<p dir="auto">I can replicate the problem exactly as in my previous post. So the the two good devices still work as expected and the two bad one does not work. And the bad ones also <em>do</em> work with the <strong>Power.powerOff();</strong></p>
<p dir="auto">So I searched up the code for  <strong>Power.timerSleep()</strong> and <strong>Power.powerOff()</strong> in the M5Unified library and they are defined in the file <strong>Power_Class.cpp</strong></p>
<p dir="auto">There is a lot of code here that I struggle to get my head around but both functions do "their stuff" and then both ends up calling the private function <strong>void _powerOff(bool withTimer)</strong> but  <strong>Power.timerSleep()</strong>  sets <strong>withTimer</strong> "true" whereas <strong>Power.powerOff()</strong> sets it "false" Which seems reasonable taking the variable name into account.</p>
<p dir="auto">So I changed[1] <strong>_powerOff(true);</strong> call to  <strong>_powerOff(false);</strong>  for the  <strong>Power.timerSleep()</strong> case and then the two "bad" devices started to work with <strong>Power.timerSleep()</strong> as well</p>
<p dir="auto">[1] line 709 in <strong>Power_Class.cpp</strong> if anyone is interested.</p>
]]></description><link>https://community.m5stack.com/post/25105</link><guid isPermaLink="true">https://community.m5stack.com/post/25105</guid><dc:creator><![CDATA[Cognitive5525]]></dc:creator><pubDate>Tue, 07 May 2024 19:45:44 GMT</pubDate></item><item><title><![CDATA[Reply to BUG: in Power.timerSleep() UIFlow2.0 for Core-INK on Tue, 07 May 2024 12:21:16 GMT]]></title><description><![CDATA[<p dir="auto">OK this is really strange!</p>
<p dir="auto">First: The length of the sleeping period does not matter....</p>
<p dir="auto">I'm using the following short test code in <a href="http://main.py" target="_blank" rel="noopener noreferrer nofollow ugc">main.py</a> (and <a href="http://boot.py" target="_blank" rel="noopener noreferrer nofollow ugc">boot.py</a> is empty):</p>
<pre><code>import M5
import time

M5.begin()
M5.Widgets.fillScreen(0xffffff)
label0 = M5.Widgets.Label("label0", 61, 55, 1.0, 0xffffff, 0x000000, M5.Widgets.FONTS.DejaVu18)
time.sleep(3)
#M5.Power.powerOff()
M5.Power.timerSleep(20)
</code></pre>
<p dir="auto">I have put the above code on four different CORE-INK devices (by cloning the first to the three others) and two of them are working and two are are not working. "Working" means switch off board power (5Vout  -&gt; 0) and wakes up after 20 seconds. "Not working" means still "wakes up" after 20 sec. but 5Vout remains on all the time.</p>
<p dir="auto">However if I change the code on the two "bad" devices to use <strong>Power.powerOff()</strong> (i.e. un-comment the second last line) they switch off correctly (5Vout -&gt; 0 ) and then (of course) remain switched off.<br />
(All tests performed while running on the internal battery only)</p>
<p dir="auto">I assume that <strong>Power.timerSleep(20)</strong> basically do something  like the following:</p>
<ul>
<li>#1. set the registers in the RTC (via I2C) with the correct timeout and put it in "INT-mode"</li>
<li>#2. set pin12 low to switch of the hole board.</li>
</ul>
<p dir="auto">and  <strong>Power.powerOff()</strong> do just #2.</p>
<p dir="auto">Do the two functions set pin12 low in different ways? Or is it some kind of critical timing? Or is #1 step affecting the "low signaling" of pin12 in some unknown way?</p>
]]></description><link>https://community.m5stack.com/post/25088</link><guid isPermaLink="true">https://community.m5stack.com/post/25088</guid><dc:creator><![CDATA[Cognitive5525]]></dc:creator><pubDate>Tue, 07 May 2024 12:21:16 GMT</pubDate></item><item><title><![CDATA[Reply to BUG: in Power.timerSleep() UIFlow2.0 for Core-INK on Mon, 06 May 2024 20:35:55 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/30733">@Cognitive5525</a></p>
<p dir="auto">I've selected 60 seconds arbitrarily - so no, I don't think a longer shutdown time will change things.</p>
<p dir="auto">That said, if you are running your M5CoreInk from battery but it still doesn't do a full shutdown then I am afraid I am out of ideas at this point in time.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/25083</link><guid isPermaLink="true">https://community.m5stack.com/post/25083</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Mon, 06 May 2024 20:35:55 GMT</pubDate></item><item><title><![CDATA[Reply to BUG: in Power.timerSleep() UIFlow2.0 for Core-INK on Mon, 06 May 2024 15:47:20 GMT]]></title><description><![CDATA[<p dir="auto">Thanks Felix,<br />
I'll try to increase the sleep time  tomorrow when I'm back in the office.</p>
<p dir="auto">I have however made the exact test you suggest and I could <em>not</em> switch on with the power button during the sleep time unless I pressed the reset button first. And if I only pressed the reset button during the sleep time it would still wake up after 10 sec.</p>
<p dir="auto">If increasing the sleep time helps I then wonder:  What is the minimum sleep time (apparently &gt; 10 sec)? And why would it be so long?</p>
]]></description><link>https://community.m5stack.com/post/25073</link><guid isPermaLink="true">https://community.m5stack.com/post/25073</guid><dc:creator><![CDATA[Cognitive5525]]></dc:creator><pubDate>Mon, 06 May 2024 15:47:20 GMT</pubDate></item><item><title><![CDATA[Reply to BUG: in Power.timerSleep() UIFlow2.0 for Core-INK on Mon, 06 May 2024 14:53:43 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/30733">@Cognitive5525</a></p>
<p dir="auto">as far as I can test the <code>Turn off the device...</code> block works as it should an turns the device fully off (except for the RTC clock IC). You can verify that yourself by setting a longer turn off time, let's say 60 seconds, and then when it has turned off, try to power it on with the power button. If that works, then it was actually fully shutdown.</p>
<p dir="auto">Please note: M5CoreInk only can go into full shutdown when run from battery. (USB power keeps it on all the time.)</p>
<p dir="auto">BTW: I also confirmed that the 5 V on the Groove port are gone during full shutdown.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/25070</link><guid isPermaLink="true">https://community.m5stack.com/post/25070</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Mon, 06 May 2024 14:53:43 GMT</pubDate></item></channel></rss>