How to send Cayenne Data each minute?

Hi, there. I like to thank you for come here.

I have a sensor data temperature, I want to send the data to Cayenne each minute, and send the data to my webservice each ten minutes, but doesn’'t works. below is my code:

unsigned long t_cayenne = 0 - 30000;
unsigned long t_post = 0 - 600000;
unsigned long t_transcurrido = millis();

void loop()
 if (t_transcurrido - t_cayenne >= 30000) //each one minute on milliseconds
    { ;        
        t_transcurrido = 0;
 if(t_transcurrido - t_post >= 600000) //each ten minute on milliseconds
     ToPostWStemp(); //Function that sends temperature data to my webservice
      t_transcurrido = 0;

but doesn’t works, and I don’t know what I’m doing bad.
Thank you, and I hope you can be able to support me.

Hi Mauricio,

That’s not the way works. should be handled every loop else I believe the http connection to the cayenne server will just be dropped and require re-initializing as in setup.

You just need to put your temp read in the virtual analog function, and Cayenne will read it every few seconds.

If you truly want to restrict the updates, then I suggest you sleep your Arduino, wake up on timer, then send your data every minute, re-establishing the cloud server connection.

I don’t know what this is buying you though.


So, isn’t it possible execute the lecture each minute in Cayenne? :frowning:

What is your objective? To save data, or save power?

You can definitely only update the value you send to Cayenne every minute, but Cayenne is going to get a value every few seconds by design.

If you don’t want to maintain a connection to the cloud service, then you can sleep, then wakeup and send.

Save data… I want to upgrade Cayenne data each minute, and after ten minutes send my data to my web service

Then I suggest you sleep it, then wakeup, redo the setup, and run for 5 seconds to ensure Cayenne gets a reading, then sleep again.You could then use a counter in non volatile ram to post to your webservice every 10th wakeup.

1 Like

It’s the only way to do this?? :U

I see no current way to reduce the read rate right now.

You could put in a feature request for this, but I expect most people aren’t concerned with the minimal amount of data the connection consumes over an ethernet or wifi connection.

If you are doing this over say a cellular modem where data is metered, it is more of a concern, but still not relatively significant.

I will be working on some code to do something similar though my concern is with conserving power. I’ll post if I get it working on my ESP-12.