How to handle POWERED DOWN in Arduino

I have my RAK5010 running very well with custom code/Arduino. The ‘setup’ and ‘loop’ functions are called as expected and I can get it to sleep between running tasks.

What I’d like to do is be able to handle/capture the POWERED DOWN event, which appears to be generated when turning off the device, however I don’t know if this is a function I need to add to my code or if the message is generated elsewhere.

I see the “POWERED DOWN” message and then a later message “### Unhandled:” in the debug output but since I’m not handling the message, my loop will just continue to run.

Thoughts?

Additional details…

The power switch causes the BG96 to send a URC (Unsolicited Result Code) of “POWERED DOWN”. I’m going to assume that I need to keep watching for this message and then shut down my loop and allow the device to turn off.

Do I need to call the “suspendLoop” and/or “systemOff” function? Or just shutdown my devices and exit the loop?

On Power Up, will the “setup” function be called again, or does it just go back into the loop?

Hi,

“POWERED DOWN” means BG96 powers off. If it powers off, the red led and blue led will be off too. If you want to go to sleep, you can catch the respond from BG96, which is “POWERED DOWN”. Then you can stop your loop.