accelerometer wake not working



  • hello,

    I tryed the code

    from pytrack import Pytrack
    #from pysense import Pysense
    from LIS2HH12 import LIS2HH12
    import pycom
    import time
    
    pycom.heartbeat(False)
    
    py = Pytrack()
    # py = Pysense()
    
    print("Wakeup reason: " + str(py.get_wake_reason()) + "; Aproximate sleep remaining: " + str(py.get_sleep_remaining()) + " sec")
    time.sleep(0.5)
    
    py.setup_int_pin_wake_up(False)
    
    py.setup_int_wake_up(True, True)
    
    acc = LIS2HH12()
    acc.enable_activity_interrupt(2000, 200)
    
    # check if we were awaken due to activity
    if acc.activity():
        pycom.rgbled(0xFF0000)
    else:
        pycom.rgbled(0x00FF00)  # timer wake-up
    time.sleep(0.1)
    py.setup_sleep(300)
    py.go_to_sleep()
    

    And it never wakes up. Not after 5 minutes nor with serious shaking.

    What am I missing?
    I saw other topics with a similar problem but unsolved. Is it something which is not supposed to work?



  • @jcaron any news?



  • @jcaron 0.0.9?? where do I get that? I'm on 0.0.8. I thought it was the latest one?
    You mean it doesn't work on 0.0.8 version?



  • @devinv Did you update the Pytrack firmware to the latest version (0.0.9)? You can check it using py.read_fw_version.

    If you keep just py.setup_sleep and py.go_to_sleep, does it wake up after the given time?

    Note that in your script, the board will go back to sleep nearly immediately after waking up. Given the time it takes for USB to come up, your only hint of a wake up will be a 100 ms flash of the LED.

    Note also that it takes a little while for the board to wake up, so if you want to know the reason for the wake up, you should indeed use get_wake_reason rather than acc.activity (which will give you the state when you call it, not when it woke up).



  • @paul-thornton thank you



  • The code looks correct.

    I dont have a Pytrack to hand untill tomorrow. If no one has responded by then Ill take a look and see if I cant work out what's going on.



Pycom on Twitter