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

    Deep Sleep Not Waking Up

    Scheduled Pinned Locked Moved FiPy
    fipypycomdeepsleepdeep sleep
    12 Posts 6 Posters 1.4k Views 7 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.
    • S Offline
      SmokeySpace
      last edited by SmokeySpace

      I'm just getting into Pycom and the Fipy, and I want it to go into deepsleep for 10 minutes, wake up, take a distance reading, and go back into deep sleep again, however when I use "machine.deepsleep(10000)" (just testing with 10 seconds) it doesn't wake up, I'm not sure what the problem is, if it's the board doesn't supply deepsleep, or if I'm missing something in my code, any help would be appreciated!

      John BairdJ 1 Reply Last reply Reply Quote 0
      • P Offline
        Paul Thornton
        last edited by

        Could you post the code your using so we can take a look?

        S 1 Reply Last reply Reply Quote 0
        • John BairdJ Offline
          John Baird @SmokeySpace
          last edited by

          @smokeyspace And the hardware in use? Taking a distance reading implies listening, or talking, to something else. What is it that measures distance and how is it interfaced?

          S 1 Reply Last reply Reply Quote 0
          • S Offline
            SmokeySpace @John Baird
            last edited by

            @john-baird I am using an ultrasonic range sensor (HC-S0R4) and calculating range from that

            1 Reply Last reply Reply Quote 0
            • S Offline
              SmokeySpace @Paul Thornton
              last edited by SmokeySpace

              @paul-thornton I’m away from my computer but I believe this is what I had -

              import time
              from machine import Pin, Timer
              import machine
              
              echo = Pin(Pin.exp_board.G7, mode=Pin.IN)
              trigger = Pin(Pin.exp_board.G8, mode=Pin.OUT)
              
              trigger(0)
              
              chrono = Timer.Chrono()
              
              def sensor():
                  chrono.reset()
              
                  trigger(1)
                  time.sleep_us(10)
                  trigger(0)
              
                  while echo() == 0:
                      pass
              
                  chrono.start()
              
                  while echo() == 1:
                      pass
              
                  chrono.stop()
              
                  distance = chrono.read_us() / 58.0
              
                  if distance > 400:
                      print("Out of range")
                  else:
                      print("Distance {:.0f} cm".format(distance))
              
                  print(“test 1”)
                  machine.deepsleep(10000)
                  print(“test 2”)
               
                  sensor()
              
              
              sensor()
              
              

              I also had the “def sensor():” function as a “while True:” statement but that did not work either

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

                @smokeyspace you may want to switch the led on and possibly change its colour at different places in your code to see if anything actually happens.

                You may also want to add a short sleep before going to deep sleep. The ESP32 may go to sleep before the UART has had the time to transmit everything (or anything).

                Also, remember that machine.deepsleep never returns. Wake up will result in a restart from the beginning of boot.py and main.py, exactly like a first boot or a reset.

                S C 2 Replies Last reply Reply Quote 0
                • S Offline
                  SmokeySpace @jcaron
                  last edited by

                  @jcaron well it prints “test 1” but not the test 2, and I knew it restarted, I was just trying to get it to wake back up before I worried about that, it doesn’t run anything at all after it goes to sleep, but I’ll try the short sleep and see if that helps

                  S 1 Reply Last reply Reply Quote 0
                  • C Offline
                    crumble @jcaron
                    last edited by

                    @jcaron said in Deep Sleep Not Waking Up:

                    Also, remember that machine.deepsleep never returns.

                    Depends :)
                    If it behaves like the pytrack, it may never go to sleep and never increase the program counter. I assume a catched i2c issue in combination with the pytrack. If the OP has a USB volt meter, he can simply verify this. If it still draws a lot of power, it does not sleep and can therefore never wake up. The software watchdog is able to get it out of this state.

                    On my system it is not easy to reproduce. It may need a few hundred deepsleeps before this error occurs.

                    S 1 Reply Last reply Reply Quote 0
                    • S Offline
                      SmokeySpace @SmokeySpace
                      last edited by

                      @smokeyspace the short sleep did not seem to work :/ The heartbeat shuts off and never comes back on and no code is run again, do I need a boot.py file and do something with that?

                      C 1 Reply Last reply Reply Quote 0
                      • C Offline
                        crumble @SmokeySpace
                        last edited by

                        Try to use the FiPy Names for your pin configuration. FiPy pinout

                        You configured pin G7 as an input pin. But this one is used by the LTE modul as well ( G7 == P20 == LTE_TX ).

                        Try to use a pin which is neither used by a module of the FiPy nor the expansion board. Or you can try to deinit the LTE modul.

                        S 1 Reply Last reply Reply Quote 2
                        • S Offline
                          SmokeySpace @crumble
                          last edited by

                          @crumble That worked! Thank you so much! I just switched G7 to G9 and it worked like a charm!

                          1 Reply Last reply Reply Quote 2
                          • S Offline
                            SevenW @crumble
                            last edited by

                            @crumble : do you have more information on this failure mode or found a work around? I think I have been bothered by something similar, See this post: Fipy does not always wake from deepsleep:

                            My Fipy does not wake once in a while, and can only be recovered by pressing the reset button or power cycling the module.

                            I can always wake it. Either by a reset from deepsleep or by Watchdog timer. It might be that in the case of the watchdog timer wakeup it is not deepsleep, and when it is in deepsleep it does not wake by the WDT. That would explain all the behaviour I observe. Needless to say is that I need it to go to deepsleep always for battery life reasons.

                            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