I’m attempting to develop a circuit which needs to retain variable information after removing power (which may last up to a week or two). I’m powering my mesh from USB and plan to connect a LiPo back-up. My plan is to detect the power loss and back up the necessary data to EEPROM for the next restart, then go to a deep sleep.
I’ve found posts on how to detect the power loss on the Gen 2 devices (through PCIM), but it does not appear that the mesh devices have this ability. Does anyone know how to do this (preferably software solution only. I’d rather not dedicate a pin and interrupt.)
Also, the notes seem to indicate that sleep is not functioning yet on mesh. Is that accurate? If so, is there a workaround? Thanks, all.
@dadick83, sleep modes have NOT been developed yet for mesh devices as the nRF52840 supports a much richer set than the Gen 2 devices.
The Argon and Xenon had a different power management circuit than the Boron (which is like the Electron). However, both the Argon and Xenon have a VUSB_DET signal which is presented at P0.12 of the rRF52840 so I would say that yes, you will be able to detect if USB is applied or not.
Thanks for the response but looking at both the Argon and Xenon datasheet pinouts, it looks like P0.12 is not independently available (it appears from your reference to VUSB_DET it may be labelled as VBUS, and that DOES provide the USB voltage out). I assume I can tie VBUS to a digital pin and set an interrupt on that pin, but that would be a hardware solution, not a software-only method. Can an interrupt be set on that pin (it doesn’t appear so in the docs)? Is there another way?
Thank you! I’m still new at Particle products, so I’m still trying to get a handle on the docs. While I understand your code, I have a couple questions, if you don’t mind.
1, is the include particle library necessary and what does it do? Can you point me to a reference for it, I can’t find that. (I’m assuming there’s other functions in there that I’m missing out on)
2. What was the purpose for the log.info entry? Would that be used in conjunction with the publish, or only useful if I have a terminal connected via serial?
@rickkas7, any chance this carries over to the Boron? I gave it a shot and it is throwing the following when trying to compile “‘PWR’ was not declared in this scope”. I have double checked that I included Particle.h.
I am creating a deep freezer monitor and I am powering Boron via USB for normal operation with battery for backup if power is lost. My goal is to detect if power is loss so I am trying to poll the USB power status.
I was trying to use this code on a Boron, but I get an error message saying “‘PWR’ was not declared in this scope”. - is this code not working on the Boron?
What I am trying to achieve is the following: I have a system running on a Boron which I want, in order to save battery power, to go automatically into sleep mode when the battery is not charging, i.e. when the system is not connected to USB/a charger. This is because I wanted to use something like:
powerState = digitalRead(PWR);
and then start a count-down timer, if the system is not charging anymore. Is there any other or better way to do that?