@rick.roades peaked my curiosity about using a PIR to wake a battery powered Boron in this post.
I have a Boron already wired to a TPL5111 for an external timer and allows me to Shutdown the Boron with it’s EN pin, So I added a PIR to test.
In addition to the timer function of the TPL, we can also pull the Delay Pin Low to Start a Cycle (Wake the Boron from EN pin Shutdown). The PIR has a very low current and pulls it’s output LOW during Motion.
The PIR and TPL are both powered by the LI+ pin.
The Boron remains in shutdown until Motion is sensed, the PIR pulls the TPL delay pin to Ground, causing the Boron to Startup. It works !
Right now, my Code makes the Boron Shutdown 2 minutes (adjustable) after Motion has stopped.
But if a squirrel decided to hang-out in front of the PIR all day, the Boron wouldn’t know how often it’s actually Publishing across EN Pin Shutdowns.
That’s not a big deal for a Solar Boron, but it brings up a Question:
What’s the best method to store the last “TIME related variable” that the Boron Shutdown (that will survive a shutdown from the EN pin being Grounded). I’m looking for a way to prevent continuous Motion causing repeated Startup Cycles, mainly the "motion "publish. I didn’t see BackupRAM or RTC in the Boron Docs. I think I would write to EEPROM (figure out some form of wear leveling), and once Manual System Mode is available have the Boron read EEPROM in setup() and decide if it should continue the boot process (modem, etc) or not. It seems to me this would still be useful when Pin Sleep Mode is available (for non-Solar, Gen3 battery devices).
AFAICT the nRF52840 does have a BackupRAM feature, but it might not have been implemented or just wasn’t documented yet.
It’s still worth a try - unfortunately, I haven’t got a device with me right now to test , but this code builds without errors
const int LED = D7;
retained int x;
void setup() {
pinMode(LED, OUTPUT);
digitalWrite(LED, (x == 123));
x = 123;
}
Your code appeared to work. No LED on the first run, pressed reset, then LED on.
Unfortunately, it doesn’t survive a Shutdown from the EN Pin (Starts over w/ LED Off until a reset, then On).
It’s good to know the BackupRAM feature works. I’m thinking that’s the best solution for when we get Pin Sleep.
Thanks again @ScruffR