<?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[Wake M5 Tough from Light Sleep with GPIO Input???]]></title><description><![CDATA[<p dir="auto">Hi all.</p>
<p dir="auto">I'm totally new to the whole M5 world.  I have a M5 Tough that I have been playing with, initially coding it with UiFlow, but now using PlatformIO in VSC with arduino based libraries.</p>
<p dir="auto">I've pretty much run into a wall straight away with my tinkering and I hope someone can help me out.</p>
<p dir="auto">What I would like to do is, place the Tough into a LightSleep mode and then wake it up from either a GPIO  Input interrupt and also if the screen is touched.</p>
<p dir="auto">I stared playing with the sleep example in the M5Tough library, hacking it up a bit (Listed below)  to introduce an Input on Pin 19 and associate it with an input interrupt.  I've attached a simple push button circuit and proved it worked with a simple input pin read before trying to use it as the wake interrupt trigger.<br />
And I've tried all sorts of things with the interrupt handler code, but I just cant find a way to wake the Tough out of sleep.  The only way the controller wakes in my test code is that the sleep timer expires.  In fact I'm at the point of thinking the interrupt is not being seen at all when I push the button while the Tough is asleep.</p>
<p dir="auto">It would be greatly appreciated if anyone help me out with ideas, or better still, a piece of sample code?</p>
<p dir="auto">Cheers,<br />
galeap</p>
<h3>For ref here is the latest hack code I've been playing with:</h3>
<p dir="auto">/*</p>
<hr />
<ul>
<li>Copyright (c) 2021 by M5Stack</li>
<li>
<pre><code>             Equipped with M5Tough sample source code
</code></pre>
</li>
<li>
<pre><code>                     配套  M5Tough 示例源代码
</code></pre>
</li>
<li>Visit the website for more information：<a href="https://docs.m5stack.com/en/core/tough" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.m5stack.com/en/core/tough</a></li>
<li>获取更多资料请访问：<a href="https://docs.m5stack.com/zh_CN/core/tough" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.m5stack.com/zh_CN/core/tough</a></li>
<li></li>
<li>describe：Sleep--Axp电源休眠</li>
<li>date：2021/7/21</li>
</ul>
<hr />
<p dir="auto">*/<br />
#include &lt;M5Tough.h&gt;</p>
<p dir="auto">void wakeUp() {<br />
// Wake-up interrupt handler<br />
// M5.Power.wakeUp();<br />
M5.Axp.RestoreFromLightSleep();<br />
Serial.println("Interupt Wake Up.");<br />
M5.Lcd.println("Interupt Wake Up.");</p>
<p dir="auto">}</p>
<p dir="auto">/* After M5Tough is started or reset<br />
the program in the setUp () function will be run, and this part will only be run once.<br />
在 M5Tough 启动或者复位后，即会开始执行setup()函数中的程序，该部分只会执行一次。 */<br />
void setup(){<br />
M5.begin(); //Init M5Tough.  初始化 M5Tough</p>
<p dir="auto">// Set GPIO Pin 19 as an input<br />
pinMode(19, INPUT_PULLUP);</p>
<p dir="auto">// Attach the wake-up interrupt to GPIO Pin 19<br />
attachInterrupt(digitalPinToInterrupt(19), wakeUp, RISING);</p>
<p dir="auto">M5.Lcd.setTextFont(2);  //Set font size to 19.  设置字体大小为2</p>
<p dir="auto">Serial.println("Light / Deep Sleep Test."); //The serial port prints the formatted string with a newline.  串口输出格式化字符串并换行<br />
M5.Lcd.println("Light / Deep Sleep Test."); //The screen prints the formatted string and wraps it.  屏幕打印格式化字符串并换行</p>
<p dir="auto">}</p>
<p dir="auto">void loop()<br />
{<br />
Serial.println("Going to light sleep for 15 seconds.");<br />
M5.Lcd.println("Going to light sleep for 15 seconds.");</p>
<p dir="auto">delay(2500);  //delay 2500ms.  延迟2500ms</p>
<p dir="auto">M5.Axp.LightSleep(SLEEP_SEC(15));  //Wake up after 5 seconds of light sleep, the CPU will reboot and the program will start from the beginning.  轻度睡眠10秒后重新启动，程序从下一行继续执行</p>
<p dir="auto">Serial.println("Wakeup from light sleep.");<br />
M5.Lcd.println("Wakeup from light sleep.");<br />
delay(10000);<br />
}</p>
]]></description><link>https://community.m5stack.com/topic/5316/wake-m5-tough-from-light-sleep-with-gpio-input</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Mar 2026 15:41:15 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/5316.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 19 May 2023 13:00:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wake M5 Tough from Light Sleep with GPIO Input??? on Tue, 13 Jun 2023 16:16:29 GMT]]></title><description><![CDATA[<p dir="auto">Thank you <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/4037">@felmue</a> !</p>
]]></description><link>https://community.m5stack.com/post/21195</link><guid isPermaLink="true">https://community.m5stack.com/post/21195</guid><dc:creator><![CDATA[dichi]]></dc:creator><pubDate>Tue, 13 Jun 2023 16:16:29 GMT</pubDate></item><item><title><![CDATA[Reply to Wake M5 Tough from Light Sleep with GPIO Input??? on Fri, 09 Jun 2023 15:28:12 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/44253">@dichi</a></p>
<p dir="auto">thank you for reporting. I've move all my Arduino examples into folders of the same name (since Arduino IDE expects it that way).</p>
<p dir="auto">I've fixed above link.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/21147</link><guid isPermaLink="true">https://community.m5stack.com/post/21147</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Fri, 09 Jun 2023 15:28:12 GMT</pubDate></item><item><title><![CDATA[Reply to Wake M5 Tough from Light Sleep with GPIO Input??? on Fri, 09 Jun 2023 14:50:28 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/4037">@felmue</a>,<br />
I'd like to check your example, but seems to be no longer online.</p>
<p dir="auto">Could you re-upload it?</p>
<p dir="auto">Many thanks,<br />
Diego</p>
]]></description><link>https://community.m5stack.com/post/21145</link><guid isPermaLink="true">https://community.m5stack.com/post/21145</guid><dc:creator><![CDATA[dichi]]></dc:creator><pubDate>Fri, 09 Jun 2023 14:50:28 GMT</pubDate></item><item><title><![CDATA[Reply to Wake M5 Tough from Light Sleep with GPIO Input??? on Sun, 21 May 2023 23:19:08 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 very much for the super fast reply and the sample code, it works a treat.</p>
]]></description><link>https://community.m5stack.com/post/20912</link><guid isPermaLink="true">https://community.m5stack.com/post/20912</guid><dc:creator><![CDATA[galeap]]></dc:creator><pubDate>Sun, 21 May 2023 23:19:08 GMT</pubDate></item><item><title><![CDATA[Reply to Wake M5 Tough from Light Sleep with GPIO Input??? on Fri, 09 Jun 2023 15:25:28 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/42398">@galeap</a></p>
<p dir="auto">please find an example <a href="https://github.com/felmue/MyM5StackExamples/blob/main/M5Tough/LightSleepWakeFromTouch/LightSleepWakeFromTouch.ino" target="_blank" rel="noopener noreferrer nofollow ugc">here</a> about how M5Tough can wake up from touch.</p>
<p dir="auto">Info: the same code (with a different GPIO) can be use to wake from GPIO.</p>
<p dir="auto">Note: <code>attachInterrupt()</code> only works when ESP32 is running so you cannot use it while ESP32 is in light or deep sleep mode.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/20899</link><guid isPermaLink="true">https://community.m5stack.com/post/20899</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Fri, 09 Jun 2023 15:25:28 GMT</pubDate></item></channel></rss>