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

    machine.deepsleep does not 'reset'

    Scheduled Pinned Locked Moved Getting Started
    deep sleeptimesleep
    2 Posts 2 Posters 596 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 am encountering a problem using machine.deepsleep() using a LoPy4 on an expansion board 3.0.
      The code counts pin interrupts and periodically publishes the total count. The code maximises deepsleep.
      The sensor count uses Pin_deepsleep_wakeup and the total time interval between publish uses machine.deepsleep()
      The code all works fine until the time config.interval is complete and wake_reason == 1.
      After the LoRa_publish is called the final line of code machine.deepsleep(config.interval) does not 'reset' the deepsleep time. On entering deepsleep the LoPy immediately returns 'timer completed' indicating that the time interval passed into deepsleep() method is not the config.interval figure.

      Any ideas??? Do I have to clear some memory before I call machine.deepsleep() again ???

      import machine
      import utime
      from machine import Timer
      import pycom
      import config #user defined
      import LoRa_publish #user defined
      
      rst=machine.reset_cause()
      if rst != 3: # if not woken from deepsleep
          utime.sleep(10) #to allow ctrl+C
          pycom.nvs_set('counter', 0)
          machine.pin_deepsleep_wakeup(pins = ['P23'], mode = machine.WAKEUP_ALL_LOW, enable_pull = True)
          machine.deepsleep(config.interval)
      else:
          if (machine.wake_reason()[0])==1: #pin wakeup
              total_count = pycom.nvs_get('counter') +1
              pycom.nvs_set('counter', total_count)
              print(machine.remaining_sleep_time())
              machine.pin_deepsleep_wakeup(pins = ['P23'], mode = machine.WAKEUP_ALL_LOW, enable_pull = True)
              machine.deepsleep(machine.remaining_sleep_time())
      
          elif (machine.wake_reason()[0])==2: #RTC timer complete
              print('timer completed')
              total_count = pycom.nvs_get('counter')
              LoRa_publish.publish(total_count) #int published to TTN
              pycom.nvs_set('counter', 0)
              machine.pin_deepsleep_wakeup(pins = ['P23'], mode = machine.WAKEUP_ALL_LOW, enable_pull = True)
              machine.deepsleep(config.interval) #this does not restart a new interval
      
      
      
      1 Reply Last reply Reply Quote 0
      • V Offline
        Vinicius Pinhatari campos
        last edited by

        Hi,
        Have you fix it?
        I'm facing the same problem

        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