[SOLVED] How Particle Variables interact with the Cloud

Sorry if this has already been asked, but I couldn’t find a post that explains it.

I’m trying to understand when Particle Variables interact with the cloud. I understand from the documentation that a variable is “registered” through the Particle.variable() call, but what exactly does that mean from a data usage perspective? My guess is the handling works as follows (please correct me if I’m wrong):

  1. App starts and Particle.variable() is called with a variable and value specified. Only the variable name is sent to the cloud to register it (the value is just stored locally).
  2. App makes another call to Particle.variable() to update the variable’s value. Again, only the variable name is sent to the cloud in case it needs to be registered. (Related question: Can I update a variable value locally without hitting the cloud again??)
  3. Client makes a call to retrieve the variable value. I’m assuming this hits the device to grab the value.

Any insight on this variable register/read process would be appreciated.

Thanks,
Mike

  1. I’m not sure if only the name is sent, but otherwise you are correct about the variable getting registered in the cloud. It is true that the variable is stored locally.

  2. No. You put Particle.variable in setup(), so it is only called once at startup. You update the variable that is pointed to in theParticle.variable call just like any other variable.

  3. The client makes a call to the cloud, which then retrieves the current value form the device, and passes that on to the client.

Thanks for the quick answer, Ric! That clarifies it for me.

Mike