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

  • 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")
        print("Going into deepsleep, no backup power for GPS")
        py = Pytrack()
        print('goSleep launched')
    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):
        if int(p_in()) == 0:
            print("irq on %s",(
        py = Pytrack()
        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?

  • @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.

  • @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.

  • @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.

Pycom on Twitter