<?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[how to identify a board is connected to a deepsleep shield]]></title><description><![CDATA[<p dir="auto">I have several LoPy and LoPy4 boards.<br />
Usually I connect LoPy to a deepsleep shield, but not always.<br />
If I use the following code, I will always invoke the deepsleep library's go_to_sleep method to a LoPy, even if it is not connected to a deepsleep shield. The board will not wake from deepsleep in this case.<br />
Some deepsleep methods raise exceptions when called if there is no deepsleep shield attached (e.g. get_wake_status) however go_to_sleep does not.</p>
<p dir="auto">does anyone know how to check if a board is connected to a deepsleep shield before choosing how to put it into deepsleep?</p>
<pre><code>def sleep_to_next_time(sleep_time=interval):
    t=uos.uname()
    if t[0] == 'LoPy':
        ds = deepsleep.DeepSleep()
        ds.go_to_sleep(sleep_time/1000)
    else:
        machine.deepsleep(sleep_time)
</code></pre>
<p dir="auto">Some deepsleep methods raise exceptions when called e.g. get_wake_status however go_to_sleep does not.</p>
]]></description><link>https://forum.pycom.io/topic/4864/how-to-identify-a-board-is-connected-to-a-deepsleep-shield</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 19:37:57 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/4864.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 25 May 2019 13:28:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to how to identify a board is connected to a deepsleep shield on Sat, 25 May 2019 13:28:46 GMT]]></title><description><![CDATA[<p dir="auto">I have several LoPy and LoPy4 boards.<br />
Usually I connect LoPy to a deepsleep shield, but not always.<br />
If I use the following code, I will always invoke the deepsleep library's go_to_sleep method to a LoPy, even if it is not connected to a deepsleep shield. The board will not wake from deepsleep in this case.<br />
Some deepsleep methods raise exceptions when called if there is no deepsleep shield attached (e.g. get_wake_status) however go_to_sleep does not.</p>
<p dir="auto">does anyone know how to check if a board is connected to a deepsleep shield before choosing how to put it into deepsleep?</p>
<pre><code>def sleep_to_next_time(sleep_time=interval):
    t=uos.uname()
    if t[0] == 'LoPy':
        ds = deepsleep.DeepSleep()
        ds.go_to_sleep(sleep_time/1000)
    else:
        machine.deepsleep(sleep_time)
</code></pre>
<p dir="auto">Some deepsleep methods raise exceptions when called e.g. get_wake_status however go_to_sleep does not.</p>
]]></description><link>https://forum.pycom.io/post/28048</link><guid isPermaLink="true">https://forum.pycom.io/post/28048</guid><dc:creator><![CDATA[philwilkinson]]></dc:creator><pubDate>Sat, 25 May 2019 13:28:46 GMT</pubDate></item><item><title><![CDATA[Reply to how to identify a board is connected to a deepsleep shield on Sat, 25 May 2019 21:08:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/1904">@philwilkinson</a> <code>read_hw_version</code>, <code>read_fw_version</code> and <code>read_product_id</code> would probably be good starting points.</p>
]]></description><link>https://forum.pycom.io/post/28054</link><guid isPermaLink="true">https://forum.pycom.io/post/28054</guid><dc:creator><![CDATA[jcaron]]></dc:creator><pubDate>Sat, 25 May 2019 21:08:02 GMT</pubDate></item><item><title><![CDATA[Reply to how to identify a board is connected to a deepsleep shield on Sun, 26 May 2019 00:12:58 GMT]]></title><description><![CDATA[<p dir="auto">thanks for the response <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/1538">@jcaron</a>. Unfortunately all the methods you suggest only work on the expansion board types, not the deepsleep shield.<br />
The only way I can see to do this is to use an exception handler. Not very pythonic, but it does work.</p>
<pre><code>import deepsleep
ds = deepsleep.DeepSleep()

try:
    ds.get_wake_status()
    shield = True
except:
    shield = False
print(shield)
</code></pre>
]]></description><link>https://forum.pycom.io/post/28055</link><guid isPermaLink="true">https://forum.pycom.io/post/28055</guid><dc:creator><![CDATA[philwilkinson]]></dc:creator><pubDate>Sun, 26 May 2019 00:12:58 GMT</pubDate></item></channel></rss>