Go Down

Topic: Timed interrupts using timeLib (Read 262 times) previous topic - next topic

guzon

Pardon my ignorance but I don't understand how much of Time works on the WiFi Rev 2.  I have successfully integrated a clock in my sketch and can sync with an NTP server and display the current time.  What I do not understand is how to use the time effectively.

I would like to set interrupts to record input every 5 and 120 seconds then record data to a SQL server every 300 seconds.  How can I check for time laps?

guzon

I figured it out.

Code: [Select]

time_t fiveSec = now();

void loop() {

  if (now() >= fiveSec+5) { //run every 5 seconds
    fiveSec = now();
    executeEveryFiveSeconds();
  }
}

Go Up