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

    py.setup_int_pin_wake_up() has no effect when a button is pushed

    Scheduled Pinned Locked Moved Expansion Board
    pytracksleeppin wake upbutton
    4 Posts 2 Posters 1.1k 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.
    • F Offline
      fsergeys
      last edited by fsergeys

      I have installed a simple push button on my board connected to GND and P9(G16) of the external IO header.

      My little test code looks like this:

      def goSleep():
          print("Do not wake up by accelerometer")
          py.setup_int_wake_up(False, False)
          print("Setting P9 to listen for wakeup on falling edge")
          py.setup_int_pin_wake_up(False)
          py.setup_sleep(60)
          print("Going into deepsleep, no backup power for GPS")
          py.go_to_sleep(False)
      
      try:
          py = Pytrack()
          time.sleep(10)
          print('goSleep launched')
          goSleep()
      
      except Exception as exc:
          sys.print_exception("Exception in system init: {0}".format(exc))
      

      No matter whether I put py.setup_int_pin_wake_up(True) or py.setup_int_pin_wake_up(False) -> the button does not wake up the board.

      So to be sure my button was working, I tested with

      def pin_handler(arg):
          time.sleep(0.5)
          if int(p_in()) == 0:
              print("irq on %s",(arg.id()))
      
      try:
          py = Pytrack()
          time.sleep(10)
          print('P9 button enabled')
          p_in = Pin('P9', mode=Pin.IN, pull=Pin.PULL_UP)
          p_in.callback(Pin.IRQ_FALLING, pin_handler)
      
      except Exception as exc:
          sys.print_exception("Exception in system init: {0}".format(exc))
      

      which outputs as expected:

      irq on P9
      

      I tried other combination like enabling the accelerometer (that works) but the button never wakes up the board.

      My system:(sysname='WiPy', nodename='WiPy', release='1.17.3.b1', version='v1.8.6-849-83e2f7f on 2018-03-19', machine='WiPy with ESP32')
      The pyboard firmware is the latest pytrack_0.0.8.dfu

      What am I missing?

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

        @fsergeys when the Pytrack enter deep sleep mode, it powers down the WiPy, which means P9 is actually more or less pulled to ground.

        You would need to have your button connected to the 3v3_sensors pin rather than GND to have a difference in the signal, though you probably need a resistor somewhere in there as well.

        Note that the state of P9 during sleep is a bit weird, and in my experience you end up with bizarre voltages, which depending on the sensor used can result in levels which are not really recognised as high or low when they should. There are also parasite signals at the time you go to sleep or wake up.

        The solution we went for is to actually cut P9 on the LoPy. Note that it means you can only read the state of the button via the PyTrack’s PIC once you do that, but it does work pretty well.

        F 1 Reply Last reply Reply Quote 0
        • F Offline
          fsergeys @jcaron
          last edited by fsergeys

          @jcaron So, do I understand well that you physically cut off the pin of P9 on the Lopy? Then you got better behaviour on P9 (external IO) on the pytrack when connect to 3V3 sensor (pin 4 of the external IO)?
          Just want to be sure before I go down that route.

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

            @fsergeys yes, we physically cut the header for that pin, so the only things that remain connected are the sensor and the PIC on the Pysense in our case. The LoPy was just bringing havoc when in deep sleep mode.

            You may want to experiment by using jumper cables between the WiPy and PyTrack at first, connecting everything but that pin, but I’m pretty sure you’ll get better results that way.

            Of course things would be very different with a WiPy 3, LoPy 4 or any of the other modules that implement deeep sleep directly rather than having to rely on an external board.

            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