Arduino Sketch - Time Library

1. timeLib.h

The library install:

  1. copy clone “github.com/PaulStoffregen/Time”
  2. copy folder Time to libraries This library uses only seconds resolution
1
2
3
4
5
6
# include <TimeLib.h>
now() //returns the current time as secs since Jan 1 1970
micros() //time in microseconds
millis() //time in milliseconds
unsigned long startTime = millis // when event 1 occurs
unsigned long elapsedTime = millis()  - startTime; //when event 2 occurs

If time is saved in a queue, make sure the datatype of the queue is the same type as StartTime