Particle.variable vs. Particle.publish for Asset Tracker GPS data

Seems like Particle.publish is best method.

I assume the .publish method uses less Electron cellular data, because it only uploads GPS data to cloud when it changes. And, .variable uses more because my mobile iOS SDK app is calling .getVariable every 5-10 seconds to read GPS from the Electron.

Particle.variable …
Presently, my asset tracker Electrons expose the firmware GPS data with Particle.variable(“g”, my_Lat_Lon).
Then, my mobile iOS SDK based app reads it with [ getVariable:@“g”…

This takes a few seconds because mobile sends request to cloud, which sends to Electron, which sends back response (GPS “g” variable) to cloud, which sends to mobile.

Particle.publish …
This is faster because Electron sends GPS data, when it changes, immediately to cloud, and then cloud pushes new GPS to mobile app.

Is there a question, or is this just thinking out loud?

2 Likes

sorry – Question is this: Is the above true?

It depends on how often you publish and/or how often you’d poll. In a moving car, your location would be changing constantly, so unless you limit the rate of publishes, you’ll publish more often there.