Sorry for reviving this thread. I did not find more recent information and it seems it is still on Particle’s ToDo list (if I read correctly, postponed to 0.8.0). Has anyone found a clever workaround to minimize power?
I have tried all three system modes: AUTOMATIC, SEMI and MANUAL; in combination with System.sleep() and I found inconsistent behavior.
System.sleep(time) keeps the code running. This is partly useful because the CPU keeps running. It seems to be the best that can be achieved. It seems that since the Photon keeps running, it doesn’t matter what the value of “time” is.
I think this delay represents how long the wifi stays off, but I found that this command doesn’t turn it back on, even in AUTOMATIC mode.
System.sleep(pin,event,time) pauses execution, but it turns on the wifi and reconnects regardless of system mode. The Photon does not stay in a low power state. I wish I could use this command and that it would not reconnect in MANUAL, or even SEMI mode.
My goal is to keep the Photon asleep for 15 seconds, then check if it should reconnect to publish data. In the end, the Photon sleeps for 14 minutes and is awake for 1 minute. The wifi is on only during that minute. This allows me to send updates and check status at a predictable time of day.
For now I have decided to stay in MANUAL mode.
The code below is what I adopted for now, but power is not minimized.
void loop()
{
if (Time.minute() % 15 == 0) //Do this every 15 minutes, for the whole minute
{
if (!Particle.connected())
{Particle.connect();}
Particle.process();
.
.
Do stuff
.
.
}
else //turn off wifi, doesn't pause code
{
System.sleep(15);
}//end else
} //end loop()
This code uses less power, but I would like to avoid getting online/offline events every 15 seconds.
void loop()
{
if (Time.minute() % 15 == 0) //Do this every 15 minutes, for the whole minute
{
.
Do stuff
.
}
else //pause execution and turn off wifi. Resume if level change on D2 or after 15 seconds
{
System.sleep(D2, CHANGE, 15);
}//end else
} //end loop()
Finally, I wish flash updates could be queued and that the Photon would check for that when it reconnects to the cloud.
Then I would not need to keep the Photon idling for 1 minute, just in case there is an update.