Hello. Thanks for coming!
I got two data variables:
data temp1
and data temp2
I want to send the data temp1 every minute, and THEN later of ten minutes, send the data variables to HTTP/POST
using the millis() function but I don't know if is correctly (I solve the post) only I need make the counter. I have the code:
void loop()
{
unsigned long t_actual = 0;
unsigned long t_corrido = millis();
const long t_post = 600000;
Cayenne.run(); //This is the function that sends data to the first post
if(t_corrido == t_post)
{
ToPostWStemp(); //This is the function that sends data to the second post
t_actual = t_corrido;
}
t_actual = 0; //Initialize the actual time from 0
}
Halo, vaj... I got a new code, and I guess is so much better than previous...
I tested, but the post doesn't send :S
void loop()
{
unsigned long t_cayenne = 0;
unsigned long t_post = 0;
if (millis() - t_cayenne >= 60000)
{
// Do this every 60 seconds
Cayenne.run();
// Keep track of the last time this code ran, so we know
// when to run it next time
t_cayenne = millis();
}
if (millis() - t_post >= 600000)
{
ToPostWStemp();
t_post = millis();
}
}
The loop() function gets executed over and over again. Defining t_cayenne outside of a function (that is, declared globally) sets t_cayenne to zero once and allows it to preserve its value instead of repeatedly being reset to zero.