Particle.variable question (Mesh related)

I’m using Xenons and an Argon to gather and publish data. The Xenons publish to the Mesh and the Argon picks up the data and publishes as a Particle.variable.

The issue I have, is that when the Xenon goes offline, the variable on the Argon ‘freezes’ to it’s last known value. Which means I can’t tell if there’s an issue with the Xenon forwarding data.

Is there a simple workaround, or does the particle.variable have a TTL?

I’m sure in the future, Particle will be adding Mesh functions which will give us more insight into the network health status. But in the meantime, I’d probably add another variable to track the time of the last update, or add some sort of heartbeat function, and use a variable to flag when when the heartbeat is still going or has stopped.


@Wedgie, besides @dougal’s great suggestions, Particle.variables are not published to the Cloud, they are requested from the device on demand. So TTL doesn’t apply. Having an “age” for the variable is a great idea as is the heartbeat approach. Your Argon can keep a timer of the last time it received an update from the Xenon, creating it’s own TTL. Instead of a separate variable to present this time, the Argon could set the value of the variable to zero or an invalid number after when the timer reaches a max time to indicate the “stalled” value.


Great suggestions! This will further my programming skills… I’m currently using a handler to listen for mesh events (mesh.subscribe). In terms of where to place a heartbeat function does it make sense to add it to my main Loop? Although I have it working, it’s. not clear to me where in my sketch the code actually picks up and processes the handler function when it sees a mesh event. I can’t put the heartbeat into the handler function as that won’t get triggered if the Xenon is offline and not publishing… does that make any sense?

@Wedgie, you CAN start a timer in the subscribe handler which is the ideal spot. When the Xenon publishes and the Argon receives the message, you start a millis() time. In loop() if that timer exceeds a preset limit, it sets the Particle.variable to an invalid value indicating the Xenon has not published in time. This “acts” like a heartbeat indicator.

Another approach is to create a separate heartbeat pub/sub. Do a search on “mesh marco” and you will find a “marco-polo” type heartbeat mesh stability tester.