Storing a variable persistently

As far as my understanding goes, I can use the cloud interface to expose a variable so that I can read it from the internet. However, what I would like to do is to set a variable via the internet so that it stays set even if I reboot my Particle. As an example, say that I want an integer setting to be used by my Particle. I would like to set it via the cloud interface, and I would like it to stay set: whenever I turn off my Particle, when it is turned back on I would like it to fetch the value again from the cloud, and use it.

Is it possible to do something like this?


If you are asking “can I store data (like a variable) into the Particle Cloud?” I believe the answer is “No”.

If you are asking “can I retrieve some data from a server (where I store my value) each time I start up my Particle?” the answer would be “yes”.

Are you looking to retrieve a stored value from a server?

Well. I was hoping to store the value on the cloud, but I guess I can store it on a server and then retrieve it when I start up the Particle.

Can I do such a thing?

Is there something like an urlopen equivalent for Particle?

What about this: ?

1 Like

I thought about this, but how can I set the value via the internet?

Use a Particle.function(), pass it as an argument, then store that?


There’s no way to do this at present - once a device is powered off, then the variables are not available. However, this is on our roadmap!

1 Like

@mdma have you given some thought to pairing up with other cloud PaaS such as Pubnub, Firebase ?

Pubnub: flexible and simple messaging to and from photon. Mobile push notifications from the photon.

Firebase: persist data even when photon is powered off. At startup, the photon reads from the dB and refreshes its RAM.

Your cloud variable concept is a little bit like a 2 way binding between Firebase and a Web page.

This is something I am really looking out for.
I have a product that has variables that need to be set remotely by the customer. Currently I use the suggestion Moors7 made a few posts up with Particle.Function().

However it would be much better if the values are stored in a database on my dashboard that get called on by the particle during startup using an ID (particle ID or one stored in EEPROM) to get a string of variables that can be processed and put into the different variables.

Then you might want to use webhooks (or direct pub/sub)