I have a project that uses photon nodes collecting environmental data running on batteries. Because the nodes run on batteries, the nodes use ‘SLEEP_MODE_DEEP’ to save the batteries. My problem was (is) that I needed a way to take the nodes out of deep sleep mode remotely so that firmware upgrades could be done OTA. I devised a way, using control software running on a ‘master’ node.
The master node has a ‘modeflag’ variable that can be changed with a function call from the CLI. That is the easy part, the rest gets a little complicated.
The battery nodes also have a ‘modeflag’ variable that controls if the node uses deep sleep. The trick is to get the new mode change from the master node to the proper battery node. Each battery node has a unique ID number. Here’s where we play ping pong.
When a battery node wakes up and comes online, it publishes an event that tells its mode (Sleep or Looping),
if the mode doesn’t match the mode that the master has, then the master publishes a ‘changeMode’ event that all the battery nodes subscribe to. If the ‘changeMode’ value matches the battery nodes ID then it’s ‘modeflag’ is changed to move that node from ‘Sleep’ to ‘Loop’ mode. Now allowing OTA updates.
The problem with all this is time, the battery node has to stay up for a least 10 seconds for all the event handshaking to complete. This is to long for battery operation! Without this overhead the nodes can complete a data transfer and be back asleep in about 2 seconds.
What seems to me would be a better solution would be to have a ‘cloud’ variable that each battery node could check when it awakes, saving all the back and forth handshaking (and time).
Also, while I’m on the subject of things I would like. The log page shows all the activity for all my photons, I only have a few, but with many nodes this gets cluttered. A way to filter this display to only the devices I am working on would be a big help.