I am very new to Arduino, but still wanted to share my workaround.
I will be following sensor parameter values as a function of time in minutes since the start of my experiment (data acquisition). I don't care about the clock, I just need elapsed time in minutes with the computer ON and powering my Arduino UNO.
to reset at the start of your experiment, hit 'clear input' on serial monitor then hit 'upload'.
Using Windows10, I can keep the experiment running while away from the computer - LOCK computer with the COM3 page open in the foreground. Sleep does not work as there is a gap in data acquisition.
That's fine, only rarely is a clock actually needed, but, in the absence of posted code it is hard to tell what you do care about. Guessing that your loop is a minute long, all you need do is include a ++ count and send that as data. Also, since it seems you are connected to PC, you can use a kosher terminal that not only records the data but also timestamps each package received, using the PC clock. Terminals, like RealTerm, Putty etc., all do this and all are freebies. You can also send the data direct to Excel, and stamp that with an Excel command. In these instances, the timestamp is the full bottle, but that doesn't cost any extra, and may even be useful.
The data type of now() is time_t, which is an unsigned long.
I usually use the RTClib library, because it has a millis-based software RTC that allows for writing code and debugging without having an actual hardware RTC, then later add the hardware RTC by changing the constructor and a line or two in setup.
#include <TimeLib.h>
int delay_sec=5; // how many seconds between time samples?
void setup() {
Serial.begin(9600);
}
void loop() {
float Elapsed_sec=now(); //important to define these as 'float' for precision
float Elapsed_min=Elapsed_sec/60; //important to define these as 'float' for precision
Serial.print(Elapsed_min, 2); //time in min with 2 digits after comma
Serial.print(" ; ");
Serial.print(Elapsed_sec, 0); //time in min with 0 digits after comma
Serial.println();
delay(delay_sec*1000);
}
There are a few problems with this.
Firstly, its "blocking" code - so while in delay() it can do nothing else;
more importantly, if your program does anything else (eg the Serial.print(Elapsed_min, 2); )
(and Serial.begin(9600); is a very slow data rate)
or eg a data measurement the loop time will be 1000msec + other bits.
If you look at the BWOD sketch
you will see how you can use millis() to get the timing right - see how it uses the "interval" parameter.