Particle.publish() and Data?

Hi Gang.

For my IoT device there are going to be times when I want to use particle.publish() for monitoring certain things (for example SoC). But most of the time this will not be monitored.

If I put code in my sketch that sends a partilce.publish() event every 30 seconds and I’m not on the cloud portal watching the events is it still being broadcasted and using data?

My initial thought, if it is, is to use a config DIP switch to enable a “broadcast mode” or use particle.function() to turn on the broadcasting with software.

THANKS!

Hi @Nickbee

If you are publishing, then your device is sending the cloud even if no one is listening. That is somewhat wasteful but not that big of a deal. That is the “push” model.

There is also the “pull” model using Particle.variables that any time your monitoring code wants an update, it can ask for the variable value. Variables can be long strings that are JSON encoded so you can pack a lot of information into one variable if you need to.

There are other ways of structuring your communication that are more advanced like using subscriptions to events or Particle.functions that let you do anything you want to do really.

4 Likes

Judging by the mentioning of SoC I’d guess @Nickbee is using an Electron and for that 30sec publishes will plough through your cell data quota - so it may or may not be a “big” deal depending on your data plan.

1 Like