Pysense - knowing the reset cause



  • Hi there,

    In order to use my application, I need it to go into deepsleep, for battery life issues. Since I'm using the pysense board, I use the setup_sleep and go_to_sleep routines. However, how can I determine that the board woke up from deep sleep or it's the first time turning on?

    In the deepsleep library, there was a get_wake_status routine, which doesn't work:

    "Traceback (most recent call last):
    File "main.py", line 26, in <module>
    File "/flash/lib/deepsleep.py", line 145, in get_wake_status
    File "/flash/lib/deepsleep.py", line 76, in peek"

    Since the pysense library doesn't have such a routine, how can it be determined?

    Thanks,

    Luís



  • Ok, however, let's imagine the following situation: I boot it up, it's the first boot. It checks the nvs for a certain value, it does not find it. It sets up that value saying that the next boot isn't the first. After the deepsleep, it will know that it isn't the first boot. But, if I reset the board, it will still think that it's not the first boot.

    How can I get around this ?



  • The module itself won't know, as from its perspective it's just been powered on. Only the Pysense would know, but I have no idea if there's a flag somewhere that could be read to get that information.

    An alternative unless Pycom chime in with details (or the sources of the Pysense PIC firmware) would be to store something in flash after the first boot, and check it back on subsequent boots.

    You could also store something everytime you go to sleep with nvs_set.



Pycom on Twitter