This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Sleep until WDT timesout

Hi All,

I have up to 8 nRF52832 devices sending data back to a base unit (another nRF52832 device.)   What I'm trying to do is have the remote units wakeup at a given time,

read sensors and send message back to the base unit.  (Each remote has a unique ID that the base unit tracks the data by.)

Currently I'm using a watchdog timer to bring the device out of sleep mode (reboot and read nvram to reload system state.)

I've been trying to use:

while(1)

{

__WFE();

}

To put the device asleep, but I'm thinking the devices are waking each other up.  (I'm getting more updates than expected and battery life is lower than expected.)

Is there a better way to get the unit to stay asleep?

thanks,

Bob

Parents
  • Hello, 

    First thing I'd check is if the external sensors are in low-power mode during sleep, if some sensor stays in measuring mode it can drain your battery regardless of what your device does. 

    Second, I'd use `nrf_pwr_mgmt_run();` instead of direct call to `__WFE();` 

    Third, nRF52 can spend relatively long time in active mode during boot, I'd rather use timer interrupt to wake up from sleep and let watchdog handle only the cases where program has hanged. 

  • Hi Otso,

    Thanks for the response,  we have mosfets that turn on/off the sensors so I'm not thinking the problem is sensors draining batteries.

    Can you point to an example using nrf_pwr_mgmt_run()  with timer triggering it?

    thanks again!
    Bob

  • Hello, 

    Someone from Nordic can point you to their official examples, here's how I did it at Ruuvi:

    https://blog.ruuvi.com/ruuvi-firmware-part-11-scheduler-c95836f3105c

    That blog is a part of lot larger series and quite heavy to grasp it on its own. 

    In essence the timer interrupt adds call to data update function to Nordic scheduler, and the timer interrupt brings the tag out of the sleep. 

    First thing once tag is out of the sleep is to execute scheduled function, including data update scheduled above. 

    After scheduler has run the main loop calls yield() which in turn will call the Nordic power management function. In your case I'd add calls to switch off the mofsets in yield and switch on once the tag has exited Nordic power management. 

    You don't necessarily need to use the scheduler, just having timer interrupt is enough to bring tag out of the sleep. However I'd prefer to not run the sensor reads in timer interrupt context, as it could mask other interrupts such as SPI data ready and lock your program.

Reply
  • Hello, 

    Someone from Nordic can point you to their official examples, here's how I did it at Ruuvi:

    https://blog.ruuvi.com/ruuvi-firmware-part-11-scheduler-c95836f3105c

    That blog is a part of lot larger series and quite heavy to grasp it on its own. 

    In essence the timer interrupt adds call to data update function to Nordic scheduler, and the timer interrupt brings the tag out of the sleep. 

    First thing once tag is out of the sleep is to execute scheduled function, including data update scheduled above. 

    After scheduler has run the main loop calls yield() which in turn will call the Nordic power management function. In your case I'd add calls to switch off the mofsets in yield and switch on once the tag has exited Nordic power management. 

    You don't necessarily need to use the scheduler, just having timer interrupt is enough to bring tag out of the sleep. However I'd prefer to not run the sensor reads in timer interrupt context, as it could mask other interrupts such as SPI data ready and lock your program.

Children
No Data
Related