Deepsleep and wakeup on the same pin



  • I'm experimenting with a button to bring my Wipy to deepsleep and wakeup. Both are working individually, but not together. After going into deepsleep it immediately wakes up again. I guess the problem is due to the bouncing. I thought that I could solve the problem by setting the wakeup PIN just before going to sleep and after sufficient time to get passed by the bouncing. But that didn't work. See code below. Anybody suggestions?

    def pin_handler(arg):
    time.sleep(0.5)
    irqCounter.append(irqCounter[-1]+1)
    #print(irqCounter[-1],"--",p_in())
    if int(p_in()) == 0:
    print("Setting %s to listen for wakeup" % (arg.id()))
    machine.pin_deepsleep_wakeup(['P3'],machine.WAKEUP_ALL_LOW, True)
    print("Going into deepsleep: %s" % (arg.id()))
    machine.deepsleep(10000)

    p_in = Pin('P3', mode=Pin.IN, pull=Pin.PULL_UP)
    p_in.callback(Pin.IRQ_FALLING, pin_handler)



  • Solved: just needed to increase the timeout to 2 seconds before setting
    machine.pin_deepsleep_wakeup(['P3'],machine.WAKEUP_ALL_LOW, True)
    and then going into deepsleep


 

Hello World?

Pylife on Kickstarter - November 2018








Back Us On Kickstarter >

Pycom on Twitter