Fipy does not always wake from deepsleep
SevenW last edited by
My Fipy does not wake once in a while, and can only be recovered by pressing the reset button or power cycling the module. I am using the machine.deepsleep(nnnn) approach. I am aware of the option to use the pytrack.go_to_sleep() but in my future application there might be no pytrack.
The failure occurs somewhere between 50 to 500 deepsleeps. I made the minimal program to test it and the usbserial output alwasy stops after logging "sleep". That is why I assume it does not wake. A leave the program running so it wakes on the timer. But when stuck, it also does not wake on the button on the pytrack board anymore.
What could this be?
import machine import pycom print("wake") print(machine.wake_reason()) machine.pin_sleep_wakeup(pins = ('P14',), mode = machine.WAKEUP_ALL_LOW, enable_pull = True) sleeps = pycom.nvs_get('sleeps') + 1 pycom.nvs_set('sleeps', sleeps) print("sleep: %d" % (sleeps)) machine.deepsleep(2000)
typical output when stuck:
ets Jun 8 2016 00:22:57 rst:0x5 (DEEPSLEEP_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff8028,len:8 load:0x3fff8030,len:1984 load:0x4009fa00,len:0 load:0x4009fa00,len:19088 entry 0x400a05e4 Initializing filesystem as FatFS! wake (2, None) sleep: 123
SevenW last edited by
Experimenting with watchdogtimer (WDT) instead of or next to deepsleep:
Using the WDT with infinite machine.deepsleep() : Get stuck after anumber of cycles just like timed deepsleeps.
Combination of WDT (at boot) and deepsleep: The program seems to run forever. It now made over 14000cycles in 24 hours time. Output:
ets Jun 8 2016 00:22:57 rst:0x7 (TG0WDT_SYS_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff8028,len:8 load:0x3fff8030,len:1984 load:0x4009fa00,len:0 load:0x4009fa00,len:19088 entry 0x400a05e4 Initializing filesystem as FatFS! wake 0 sleep: 14974, DS: 2805, WD: 12167
Weird observation: In 18.7% it waks from deepsleep(2000). In the majority of cases it wakes form WDT(5000). As the deepsleep is 3 seconds shorter in this test progam than the WDT, it should always wake form depesleep (100%)
I guess there is some race condition in programming the wake timers. Any help is appreciated. Obviously this unpredictible behaviour is not giving sufficient reassurance to build a remote sensor that should be able to perform unattended for years.