Issues with periodic connection to server


I’m somewhat confused about the internal workings of Cayenne and looking for some guidance.

I would like my Arduino or MQTT device to limit connectivity with cayenne server to specific time intervals, say 30 seconds so that the wireless module doesn’t need to continuously transmit.

I tried to create a delay on the main loop, so that the Cayenne.loop(); function runs periodically (rather than continuously), but while data sent from the device to the dashboard gets updated, data from the dashboard to the device (for example toggling a switch), is completely lost and not updated on Cayenne.loop(); next run, as expected.

I first noticed this issue on a slow network. Its common for the dashboard to just say ‘device offline’ and any data to be sent to the device is lost. Again, data sent into the dashboard is updated.

Is there a way to overcome this limitation?


Dont use delays, use

Works without problems at my locations.


@cdtsilva try using millis().


The delay is not the issue. It will blocks the device for whatever duration it runs, but that wont affect the flow of code. I have tried millis() and interrupt just in case, but no difference whatsoever.

Currently the web browser seems to time out if I flip a switch and the module doesn’t respond within 2 seconds. Since I’m only running the cayenne function every 5 seconds it times out and I can never update the output. Data is received and displayed fine, for example temperature readings from the module to the browser are updated fine, whenever the sending interval is one second or one hour.

So my assumption is that the state of a switch is not saved in the cloud and therefore if the module is not available the value is lost, but on remote locations I cant ping the module every one or two seconds due to both power and data limitations.

Is there a way to write the value to the cloud and have the module sync with it once it comes online?


The retain flag should fix this, but I’m not sure what the status of that is. @rsiegel or @bestes any updates on that?