Wake-up Problem with Pyscan and the accelerometer
iot-transport last edited by
I think I have a problem with my pyscan board. The wake-up doesn't occur with the accelerometer. It's ok with the button and the timer.
The same code on my Pysense works fine (the sample code of the library).
I don't understand why it doesn't work the same on the two boards.
Thanks for your help.
The sample code which has been used:
from pyscan import Pyscan #from pytrack import Pytrack #from pysense import Pysense from LIS2HH12 import LIS2HH12 import pycom import time pycom.heartbeat(False) py = Pyscan() #py = Pytrack() # py = Pysense() # display the reset reason code and the sleep remaining in seconds # possible values of wakeup reason are: # WAKE_REASON_ACCELEROMETER = 1 # WAKE_REASON_PUSH_BUTTON = 2 # WAKE_REASON_TIMER = 4 # WAKE_REASON_INT_PIN = 8 print("Wakeup reason: " + str(py.get_wake_reason()) + "; Aproximate sleep remaining: " + str(py.get_sleep_remaining()) + " sec") time.sleep(0.5) # enable wakeup source from INT pin py.setup_int_pin_wake_up(False) # enable activity and also inactivity interrupts, using the default callback handler py.setup_int_wake_up(True, True) acc = LIS2HH12() # enable the activity/inactivity interrupts # set the accelereation threshold to 2000mG (2G) and the min duration to 200ms 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) # go to sleep for 5 minutes maximum if no accelerometer interrupt happens py.setup_sleep(300) py.go_to_sleep()```
Correct. You'll wont be able to call setup_sleep() via repl. Unless you wrap it in a function to call go_to_sleep() immediately after. setup_sleep() currently causes an issue where everything blocks untill go_to_sleep() is called. Its one we are aware of but I dont have a roadmap for a change/fix.
gnm last edited by
I don't know if this is usefull, but the command
seems to cause my problem (or al least part of it).
I have tryed executing the following simple code from REPL
from pytrack import Pytrack
py = Pytrack()
As far as I understand, this should put the board to sleep mode and wake up after 5 sec. (I don't know if executing it in REPL mode changes the behaviour). However, when execute the line
atom blocks out and I have to restart the program.
gnm last edited by gnm
I am having a similar problem with the pytrack (plus fipy). I have the latest firmware versions, but the board never wakes up. The only way recover the board is by a safe boot...:(
I don't know what could be the problem, but you are not alone.