PySense & PyTrack sleep: get time slept (like sleep time remaining) + state saving?

  • Hello,

    Is it possible to get the amount of time the pycom module has slept (when using a PyTrack or PySense module) after waking up. Kind of like the get_sleep_remaining() function but to know how long the module was sleeping before waking up?

    Let me explain why I would need this:

    My application is sleeping for a fixed amount of time (rather long). But in the event of a wakeup by movement (from the PyTrack accelerometer) I take the LoPy back to sleep for a short time (1 minute). I keep repeating this 1 minute sleep when sensing movement. (get_wake_reason()==1: go_to_sleep(1 minute)) When no movement has been detected when waking up, I then send out a LORA-payload and go back to sleep for the long sleep time.

    -> I would like to know, when the application reaches the "send lora payload" code why it got there: because of a previous movement or because the long sleep interval was reached. This is however impossible at the moment, because of the setup of my applications workflow. That's where the amount of time the module slept would come in handy: if it was very near to the large sleeping interval, I know there was no movement, else there was a movement before.

    Other method could be to store the state in NVS, but writing this repeatedly is maybe not a good choice?

  • @meirssv
    you can save this info to sd card, flash or nvs

Pycom on Twitter