how to identify a board is connected to a deepsleep shield
-
I have several LoPy and LoPy4 boards.
Usually I connect LoPy to a deepsleep shield, but not always.
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.
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.does anyone know how to check if a board is connected to a deepsleep shield before choosing how to put it into deepsleep?
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)Some deepsleep methods raise exceptions when called e.g. get_wake_status however go_to_sleep does not.
-
@philwilkinson
read_hw_version,read_fw_versionandread_product_idwould probably be good starting points. -
thanks for the response @jcaron. Unfortunately all the methods you suggest only work on the expansion board types, not the deepsleep shield.
The only way I can see to do this is to use an exception handler. Not very pythonic, but it does work.import deepsleep ds = deepsleep.DeepSleep() try: ds.get_wake_status() shield = True except: shield = False print(shield)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login