<?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[M5Paper Shutdown() &#x2F; Deep Sleep &#x2F; Wakeup]]></title><description><![CDATA[<p dir="auto">I received my M5 Paper and I'm really amazed by the product. The one thing I'm struggling with is to work efficiently with the epaper display and power. In particular, I'm not sure if the <code>M5.shutdown()</code> calls actually do something or how to get the device into deep sleep.</p>
<p dir="auto">I'm literally using the example in <a href="https://github.com/m5stack/M5EPD/blob/main/examples/Basics/RTC_BM8563/RTC_BM8563.ino" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5EPD/blob/main/examples/Basics/RTC_BM8563/RTC_BM8563.ino</a> to shutdown the device (and maybe try to wake it up). When <code>shutdown()</code> is called, the main loop seems to be still executed. When <code>shutdown()</code> is called without arguments it should never wake up, but if I do some serial print I can still see the device responding.</p>
<p dir="auto">One way that I have found to get the device actually to sleep (and to wakeup again) was to use the <code>esp_*</code> functions.</p>
<p dir="auto">If my code calls</p>
<pre><code>esp_sleep_enable_timer_wakeup(10 * 1000000);
esp_deep_sleep_start();
</code></pre>
<p dir="auto">it will actually sleep and the main loop is not executed. Is this just a bug in the M5Paper firmware? I'm not an expert in ESP and M5Stack programming so please forgive me, if I'm doing something wrong.</p>
<p dir="auto">One other curious thing is that, this only works while the device is attached with the cable to my computer, but as soon as I restart it without it being attached it doesn't work anymore.</p>
<p dir="auto">Below is an example using the deep sleep function that works while attached:</p>
<pre><code>#include &lt;M5EPD.h&gt;
#include &lt;sstream&gt;
#define uS_TO_S_FACTOR 1000000
#define TIME_TO_SLEEP 10

M5EPD_Canvas canvas(&amp;M5.EPD);
RTC_DATA_ATTR int counter = 0;

void setup() {
  M5.begin();
  M5.EPD.SetRotation(90);
  M5.EPD.Clear(true);
  M5.RTC.begin();
  canvas.createCanvas(540, 960);
  canvas.setTextSize(3);

  std::ostringstream buf;
  buf &lt;&lt; "EEPRom Counter " &lt;&lt; counter;
  canvas.drawString(buf.str().c_str(), 45, 350);

  uint32_t vol = M5.getBatteryVoltage();

  if (vol &lt; 3300) {
    vol = 3300;
  } else if (vol &gt; 4350) {
    vol = 4350;
  }
  float battery = (float)(vol - 3300) / (float)(4350 - 3300);
  if (battery &lt;= 0.01) {
    battery = 0.01;
  }
  if (battery &gt; 1) {
    battery = 1;
  }
  buf = std::ostringstream();
  buf &lt;&lt; "Battery " &lt;&lt; (battery * 100) &lt;&lt; "%";
  canvas.drawString(buf.str().c_str(), 45, 550);
  canvas.pushCanvas(0, 0, UPDATE_MODE_DU4);
  ++counter;

  delay(5000);
  // Sleep for 5 seconds.
  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
  esp_deep_sleep_start();
}

void loop() {}
</code></pre>
<p dir="auto">My original assumption was that I replace the last two lines with <code>M5.shutdown(TIME_TO_SLEEP)</code> to achieve similar results, but the devices simply does not wakeup again.</p>
<p dir="auto">I would be really great if someone has some more ideas :)</p>
<p dir="auto">Thanks!</p>
]]></description><link>https://community.m5stack.com/topic/2892/m5paper-shutdown-deep-sleep-wakeup</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Mar 2026 23:27:16 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/2892.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Feb 2021 08:06:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to M5Paper Shutdown() &#x2F; Deep Sleep &#x2F; Wakeup on Fri, 05 May 2023 09:22:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/7975">@jop</a> said in <a href="/post/13375">M5Paper Shutdown() / Deep Sleep / Wakeup</a>:</p>
<blockquote>
<p dir="auto">overload-2  int shutdown( int seconds );</p>
</blockquote>
<p dir="auto">The timer function of the BM8563* is based on a 8 bit counter which can be set to be controlled by a clock frequency of 4096, 64, 1 or 1/60 Hz. This means it can timeout with following max interval @ resolution:</p>
<p dir="auto">62,3 ms @ 244,1 µs<br />
4 s @ 15,5 ms<br />
255 s @ 1 s<br />
15300 s (255 min) @ 60 s (1 min)</p>
<p dir="auto">so intervals above 255 seconds (4 min and 25 seconds) needs to be timed at one minute resolution.<br />
I have however tested this on my CoreINK (UiFlow/mocropython) and found that it rounds down in intervals of 2 minutes (120 s) for some reason.<br />
I made a script to that just put the unit to sleep but increases the sleep interval with 10 sec every time and then uses the clock to measure the actual sleep time. This was the result:</p>
<p dir="auto"><img src="/assets/uploads/files/1683278469264-4835f713-9fcf-4986-a3f7-f9f9ca8e3512-image-resized.png" alt="0_1683278473886_4835f713-9fcf-4986-a3f7-f9f9ca8e3512-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">*)<a href="https://www.nxp.com/docs/en/data-sheet/PCF8563.pdf" target="_blank" rel="noopener noreferrer nofollow ugc"> BM8563 datasheet </a></p>
]]></description><link>https://community.m5stack.com/post/20752</link><guid isPermaLink="true">https://community.m5stack.com/post/20752</guid><dc:creator><![CDATA[Cognitive5525]]></dc:creator><pubDate>Fri, 05 May 2023 09:22:05 GMT</pubDate></item><item><title><![CDATA[Reply to M5Paper Shutdown() &#x2F; Deep Sleep &#x2F; Wakeup on Sat, 18 Mar 2023 19:59:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/34671">@casascius</a> How did you even get that far? I have made a project using the new Unified library, and I can not even find the shutdown() functions at all.<br />
EDIT: with the unified library, I am simply trying:</p>
<p dir="auto"><code>M5.Power.timerSleep(600);</code></p>
<p dir="auto">Even when on USB power, this is 'caught', and so far wakeup is reliable.</p>
]]></description><link>https://community.m5stack.com/post/20377</link><guid isPermaLink="true">https://community.m5stack.com/post/20377</guid><dc:creator><![CDATA[timattrn]]></dc:creator><pubDate>Sat, 18 Mar 2023 19:59:59 GMT</pubDate></item><item><title><![CDATA[Reply to M5Paper Shutdown() &#x2F; Deep Sleep &#x2F; Wakeup on Tue, 14 Feb 2023 16:45:18 GMT]]></title><description><![CDATA[<p dir="auto">I'm coming in a bit late, but fought with this a little bit.</p>
<p dir="auto">For me, <code>shutdown()</code> wouldn't wake up at all.  The ultimate cause was that the i2c bus wasn't getting properly initialized (another issue for another post -- touchpanel related) so the command to the clock chip was never getting sent.</p>
<p dir="auto">Once it got sent, doing a <code>shutdown(10)</code> to wake up after 10 seconds worked properly for me... in fact, so properly, you couldn't turn the device off because the alarm persists until deactivated.  <code>shutdown(-1)</code> in setup() (after initializing i2c) is necessary to clear the timer alarm upon sketch restart (which I determined by inspecting the library source).</p>
<p dir="auto">Also by inspecting the source and datasheet, overload 4 that Jop says isn't working, I am guessing is because he only advanced the day of month.  It looks as though the clock chip compares not just hour/minute/day, but also the day of week (e.g. Thursday) and, reviewing the source code, it doesn't ever consider the month or year at all, nor does the chip even have registers to alarm on these.  But it has one for the weekday, so if you don't advance the weekday, the comparison will fail per the datasheet.</p>
]]></description><link>https://community.m5stack.com/post/20078</link><guid isPermaLink="true">https://community.m5stack.com/post/20078</guid><dc:creator><![CDATA[casascius]]></dc:creator><pubDate>Tue, 14 Feb 2023 16:45:18 GMT</pubDate></item><item><title><![CDATA[Reply to M5Paper Shutdown() &#x2F; Deep Sleep &#x2F; Wakeup on Mon, 05 Apr 2021 09:43:05 GMT]]></title><description><![CDATA[<p dir="auto">As I promised <a href="https://community.m5stack.com/topic/2851/m5paper-wakeup-cause/11">here</a> at end of my post under another thread, the <code>shutdown()</code> is rather buggy in the way awakening is performed.<br />
I'll describe here what I experienced.</p>
<p dir="auto">Anyway one should take <a href="https://community.m5stack.com/topic/2851/m5paper-wakeup-cause/8">this advice</a> of <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/4037">@felmue</a> in account.<br />
There are different <code>shutdown()</code> <a href="https://docs.m5stack.com/#/en/api/m5paper/system_api?id=function-overload-2" target="_blank" rel="noopener noreferrer nofollow ugc">overload variations</a> and here bugs or weird things I found.</p>
<p dir="auto">My goal was holding the M5Paper as much as possible sleeping, but at intervals of every full 5 minutes he should awake for about 10 to 15 seconds, perform some tasks (sensors) and go again sleeping to the next full 5-minute moment.</p>
<ul>
<li>
<p dir="auto">overload-2  <code>int shutdown( int seconds );</code><br />
Even if I calc enough seconds to next 5-minute moment, it seems impossible to stay asleep for remaining 5 minutes. Every 3th minute it is awakening too. This consumes unnecessary double battery power.<br />
So where I want to have this wake up schedule: hh:00 hh:05 hh:10 hh:15 hh:20 ...and so on...<br />
I get this wake up schedule: hh:00 hh:03 hh:05 hh:08 hh:10 hh:13 hh:15 hh:18 hh:20 ...and so on...<br />
This overload-2 has no problems by passing the midnight  moment.</p>
</li>
<li>
<p dir="auto">overload-3<br />
<code>int shutdown(  const rtc_time_t &amp;RTC_TimeStruct );</code><br />
This variation works best. Passing midnight (so date change) is no problem but 24:00u should be given als 00:00u.</p>
</li>
<li>
<p dir="auto">overload-4<br />
<code>int shutdown( const rtc_date_t &amp;RTC_DateStruct,  const rtc_time_t &amp;RTC_TimeStruct );</code><br />
is working, but passing midnight in a way to set awake time at 00:00h and increasing the date-parameter does NOT work! Also 24:00u without increasing the date does NOT work.<br />
The only way to pass midnight is awaking just some seconds before midnight and stay awake till after midnight, do the things that has to be done (sample sensors) and go asleep for remaining period (in my case to 00:05u).</p>
</li>
</ul>
<p dir="auto">I hope others can take advantage of this info.</p>
]]></description><link>https://community.m5stack.com/post/13375</link><guid isPermaLink="true">https://community.m5stack.com/post/13375</guid><dc:creator><![CDATA[Jop]]></dc:creator><pubDate>Mon, 05 Apr 2021 09:43:05 GMT</pubDate></item><item><title><![CDATA[Reply to M5Paper Shutdown() &#x2F; Deep Sleep &#x2F; Wakeup on Sun, 21 Mar 2021 15:48:46 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/2777">@middelbeek</a></p>
<p dir="auto">Thank you for reporting back. I am glad to hear you got it working.</p>
<p dir="auto">Cheers<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/13172</link><guid isPermaLink="true">https://community.m5stack.com/post/13172</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Sun, 21 Mar 2021 15:48:46 GMT</pubDate></item><item><title><![CDATA[Reply to M5Paper Shutdown() &#x2F; Deep Sleep &#x2F; Wakeup on Sun, 21 Mar 2021 15:07:42 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> Super, now it works! Thanks, Hans</p>
]]></description><link>https://community.m5stack.com/post/13170</link><guid isPermaLink="true">https://community.m5stack.com/post/13170</guid><dc:creator><![CDATA[middelbeek]]></dc:creator><pubDate>Sun, 21 Mar 2021 15:07:42 GMT</pubDate></item><item><title><![CDATA[Reply to M5Paper Shutdown() &#x2F; Deep Sleep &#x2F; Wakeup on Fri, 19 Mar 2021 21:10:42 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/2777">@middelbeek</a></p>
<p dir="auto">sorry about that. Try:</p>
<pre><code>    gpio_hold_en((gpio_num_t) M5EPD_MAIN_PWR_PIN);
    gpio_deep_sleep_hold_en();
</code></pre>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/13143</link><guid isPermaLink="true">https://community.m5stack.com/post/13143</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Fri, 19 Mar 2021 21:10:42 GMT</pubDate></item><item><title><![CDATA[Reply to M5Paper Shutdown() &#x2F; Deep Sleep &#x2F; Wakeup on Fri, 19 Mar 2021 15:18:25 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> , I tried your proposal with Arduino IDE and my M5Stack Paper:</p>
<p dir="auto">gpio_hold_en(M5EPD_MAIN_PWR_PIN);<br />
gpio_deep_sleep_hold_en();</p>
<p dir="auto">but get an error :</p>
<p dir="auto">invalid conversion from 'int' to 'gpio_num_t' [-fpermissive]</p>
<p dir="auto">Whats going wrong?</p>
<p dir="auto">Hans</p>
]]></description><link>https://community.m5stack.com/post/13140</link><guid isPermaLink="true">https://community.m5stack.com/post/13140</guid><dc:creator><![CDATA[middelbeek]]></dc:creator><pubDate>Fri, 19 Mar 2021 15:18:25 GMT</pubDate></item><item><title><![CDATA[Reply to M5Paper Shutdown() &#x2F; Deep Sleep &#x2F; Wakeup on Thu, 25 Feb 2021 11:21:12 GMT]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I'm currently using this small work-around to differenciate the power source between battery and USB.<br />
It basically involves monitoring the voltage after initializing <em>M5.BatteryADCBegin()</em> (via <em>M5.getBatteryVoltage()</em> to be more precise). Measuring a voltage over 4200 mV (empirically evaluated!) indicates most of the time a USB-usage. Under that value, there are high chances that the device is on battery.<br />
So far, this work-around is doing its job pretty well for me.<br />
I hope it might help!<br />
Cheers,<br />
t.</p>
]]></description><link>https://community.m5stack.com/post/12677</link><guid isPermaLink="true">https://community.m5stack.com/post/12677</guid><dc:creator><![CDATA[Tbob]]></dc:creator><pubDate>Thu, 25 Feb 2021 11:21:12 GMT</pubDate></item><item><title><![CDATA[Reply to M5Paper Shutdown() &#x2F; Deep Sleep &#x2F; Wakeup on Fri, 19 Feb 2021 15:51:55 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/6436">@grundprinzip</a></p>
<p dir="auto">no worries. Thank you for sharing your conclusion. I appreciate it.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/12567</link><guid isPermaLink="true">https://community.m5stack.com/post/12567</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Fri, 19 Feb 2021 15:51:55 GMT</pubDate></item><item><title><![CDATA[Reply to M5Paper Shutdown() &#x2F; Deep Sleep &#x2F; Wakeup on Fri, 19 Feb 2021 15:46:45 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> Thanks for the explanation, I have come to a similar conclusion regarding the <code>M5.shutdown()</code> call as well :) However, this post was stuck somewhere in an approval queue so I didn't reply earlier.</p>
<p dir="auto">Thanks again!</p>
]]></description><link>https://community.m5stack.com/post/12566</link><guid isPermaLink="true">https://community.m5stack.com/post/12566</guid><dc:creator><![CDATA[grundprinzip]]></dc:creator><pubDate>Fri, 19 Feb 2021 15:46:45 GMT</pubDate></item><item><title><![CDATA[Reply to M5Paper Shutdown() &#x2F; Deep Sleep &#x2F; Wakeup on Fri, 05 Feb 2021 13:12:23 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/4560">@ksprayberry</a></p>
<p dir="auto">AFAIK the M5Paper power architecture doesn't allow to tell whether the device is powered by USB or by battery. If you have a solution I'd be interested to hear about.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/12310</link><guid isPermaLink="true">https://community.m5stack.com/post/12310</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Fri, 05 Feb 2021 13:12:23 GMT</pubDate></item><item><title><![CDATA[Reply to M5Paper Shutdown() &#x2F; Deep Sleep &#x2F; Wakeup on Fri, 05 Feb 2021 12:58:24 GMT]]></title><description><![CDATA[<p dir="auto">I had thought to use the M5.shutdown() as a means of timing or delaying between processes. I thought that's how some of the remote sensors were done. Sleep for one minute, wake up, get the weather and stock data (sensor data) and display it or process it, and then go back to sleep, but with it being ignored when plugged in versus not, it's not viable way to do it. I thought oh this will be easy and will help me avoid all the "blink without delay" approach to delaying between processes, but I was wrong. When my device was plugged in, I was getting weather and stock every 5 seconds. Doh! I don't doubt, it all lies in my inexperience. This post and your comments are very helpful in my finding the best approach though. I need to read up and see if you can check to see if you're powered by the battery or by the USB and maybe switch between the two methods, but there again, if one method works for both scenarios, maybe just stick with it.<br />
Thanks!</p>
]]></description><link>https://community.m5stack.com/post/12308</link><guid isPermaLink="true">https://community.m5stack.com/post/12308</guid><dc:creator><![CDATA[ksprayberry]]></dc:creator><pubDate>Fri, 05 Feb 2021 12:58:24 GMT</pubDate></item><item><title><![CDATA[Reply to M5Paper Shutdown() &#x2F; Deep Sleep &#x2F; Wakeup on Thu, 04 Feb 2021 21:41:35 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/6436">@grundprinzip</a></p>
<p dir="auto">you need to know that as long as M5Paper is connected and powered by USB it cannot shutdown. In order for <code>M5.shutdown()</code> to actually power off your M5Paper, it needs to run from battery.</p>
<p dir="auto">Regarding deep sleep when running from battery and not waking up again:</p>
<p dir="auto">In order for deep sleep (and light sleep for that matter) to work the ESP32 needs to be powered. M5Paper keeps itself powered via <code>M5EPD_MAIN_PWR_PIN </code>. However by default GPIOs do not keep their state in deep sleep to conserve power. Therefore ESP32 gets unpowered as soon as it enters deep sleep and as a result it never wakes up again.</p>
<p dir="auto">To change that behaviour you can use the following to lines just before going to deep sleep to keep the required GPIO state even during deep sleep (at the cost of a slightly higher power consumption during deep sleep):</p>
<pre><code>gpio_hold_en(M5EPD_MAIN_PWR_PIN);
gpio_deep_sleep_hold_en();
</code></pre>
<p dir="auto">BTW: deep sleep and light sleep are two ESP32 sleep modes, but they can only work as long as ESP32 is powered. In contrast when M5Paper is in shutdown mode everything is w/o power except for the RTC clock which then can be used to power on M5Paper via RTC timer or alarm.</p>
<p dir="auto">M5Paper (and M5CoreInk) have quite a different power architecture than other M5Stack products which can make it a bit challenging to work with. M5Paper also doesn't have a power LED (unlike M5CoreInk) so I find it quite difficult to tell whether it is powered on or off.</p>
<p dir="auto">Good luck!<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/12301</link><guid isPermaLink="true">https://community.m5stack.com/post/12301</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Thu, 04 Feb 2021 21:41:35 GMT</pubDate></item></channel></rss>