Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    how to identify a board is connected to a deepsleep shield

    Scheduled Pinned Locked Moved Expansion Board
    deepsleepmachine.deepsleshield
    3 Posts 2 Posters 265 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • philwilkinsonP Offline
      philwilkinson
      last edited by

      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.

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jcaron @philwilkinson
        last edited by

        @philwilkinson read_hw_version, read_fw_version and read_product_id would probably be good starting points.

        1 Reply Last reply Reply Quote 0
        • philwilkinsonP Offline
          philwilkinson
          last edited by

          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)
          
          1 Reply Last reply Reply Quote 0

          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
          • 1 / 1
          • First post
            Last post

          Pycom on Twitter

          Pycom