Particle Photon: Read data from the cloud

I want to use Prototype.variable to update the current state of the device periodically. In case of a system failure/reset, I then want to be able to “read” the state from the cloud and recover the Particle.

Is it possible to read variables from the Particle itself?

I’m not sure I understand what you’re asking for, but there is no persistent data storage in the Particle cloud, so there’s no way to store state there. If you want to store some state values off the device, then you would have to have your own server, or you could store it on another Particle device, and access it through the pub/sub system.

There are ways to keep the state on a device without the cloud (e.g. retained variables or EEPROM).

When you expose a Particle.variable() (which I suppose is what you actually meant when writing Prototype.variable) the cloud never gets a value pushed from the device, but exposes the value of an already present variable to the cloud when asked for it. So yes, you can read that variable on the device, since that’s where the underlying variable lives all along.

1 Like