Sleep and Battery Conservation
Sleep and Battery Conservation
Power Conservation
-
Continuously keeping the Photon 2 on uses a lot of power
-
Connection to Particle Cloud
-
Running
loop ()
-
Responding to any interrupts or inputs
-
- To limit wasting electricity and extend the time between battery charges, use sleep, which turns off some or all of the Photon 2 components
- Note: sleep for more than 10 seconds. Less than that use more power turning it on / off than you will be saved
Zzzz….Three Sleep Modes
STOP
(most wake options, highest power)ULTRA_LOW_POWER
(ULP)HIBERNATE
(fewest wake options, lowest power)
Sleep Considerations
-
Choosing the specific sleep mode and options depends on your specific application
- Some things you’ll need to consider
- How do you want to wake up the device?
- How long in between wake periods will you have?
- How quickly do you need the device to respond once it wakes?
- In general, choose the mode that uses the least power but support the features you want
Power vs. Responsiveness
Options to Wake Photon 2
ULTRA_LOW_POWER |
HIBERNATE |
---|---|
signal on input pins | signal on inputs |
time duration | time duration |
specific analog voltage | |
Serial input | |
Bluetooth | |
Wifi signal |
What Happens After Waking
Sleep Syntax
- Here is the general syntax to sleep
SystemSleepConfiguration config;
config.mode(SystemSleepMode::<<ADD SLEEP MODE>>).<<ADD WAKE OPTIONS>>;
System.sleep(config);
Sleep Example #1
- Put device in
HIBERNATE
and wake after 10 min
SystemSleepConfiguration config;
config.mode(SystemSleepMode::HIBERNATE).duration(10min);
System.sleep(config);
Sleep Example #2
- Put device in
ULTRA_LOW_POWER
and wake with a falling (HIGH
toLOW
) signal on pin D10
SystemSleepConfiguration config;
config.mode(SystemSleepMode::ULTRA_LOW_POWER).gpio(D10, FALLING);
System.sleep(config);
Sleep Example #3
- Put device in
ULTRA_LOW_POWER
, and wake with a rising (LOW
toHIGH
) signal on pin D10 or after 2 hours
SystemSleepConfiguration config;
config.mode(SystemSleepMode::ULTRA_LOW_POWER).gpio(D10, RISING).duration(2h);
System.sleep(config);
Waking but Staying Silent
-
Using the wifi to connect to the cloud takes time and uses battery
-
If you don’t need to update in real-time, you can do the following
-
Sleep the Photon 2
-
Wake up after a fixed time, but do not connect to the cloud
-
Read / store sensor data
-
Sleep the Photon 2
-
-
After a certain amount of time or number of sensor readings, you can send all the saved data to the cloud at once
Controlling Cloud Connection
- To prevent automatic connection to the cloud, use the following command at the top of your code (not inside
loop
orsetup
)
SYSTEM_MODE(SEMI_AUTOMATIC);
- When you are ready to connect to the cloud, run the following command in your code
Particle.connect();