Hi, I have some basic queries about the various Time/time/TimeLib libraries.
I am running Uno, with IDE v1.8.12, on a Windows 7 laptop. RTC is DS1307
I gather that TimeLib is the most recent version and includes “wire” , so I downloaded from Github websitehttps://github.com/PaulStoffregen/Time and installed manually.
When I “include library” via IDE I only have choice of “Time”. How do I check what actual library is loaded by compiler? Which library should I use, and how do I force that one to load?
I set my RTC using example sketch from IDE - Serial monitor matches laptop clock. Time maintained after power-off.
I then ran the simple sketch below for testing of RTC functions. It runs, but serial monitor indicates minute, second values starting from 0,0. How do I fix this?
Many example RTC sketches have " tmElements_t tm " to access components : H,M,S etc. This seems to be required for Time.h but not TimeLib.h - is that correct? My sketch seems to work without " …elements…". Do I need an equivalent function eg time = now() to interrogate current value of minutes & seconds?
Further...
If I set RTC time withing sketch (setTime(hr,min,sec etc,etc) then time display is correct.
Why does the previous RTC setting get over-written by this sketch?
As I understand TimeLib Readme notes, RTC time can be set to system time using setTime(t) function.
However compiler reports:- 't' was not declared in this scope
Compiler also reports:-
Multiple libraries were found for "TimeLib.h"
Used: C:\Users\Brian\Documents\Arduino\libraries\Time
Not used: C:\Users\Brian\Documents\Arduino\libraries\Time-master
exit status 1
This relates to my earlier question about which library should I be using?
Multiple libraries were found for "TimeLib.h"
Used: C:\Users\Brian\Documents\Arduino\libraries\Time
Not used: C:\Users\Brian\Documents\Arduino\libraries\Time-master
exit status 1
This relates to my earlier question about which library should I be using?
I would delete both of those folders, and download the TimeLib library again.
As I understand TimeLib Readme notes, RTC time can be set to system time using setTime(t) function.
However compiler reports:- 't' was not declared in this scope
Somewhere before that, there must have been a variable named t declared, with the appropriate type (probably time_t), and initialized.
brianf53:
3) I then ran the simple sketch below for testing of RTC functions. It runs, but serial monitor indicates minute, second values starting from 0,0. How do I fix this?
By calling setSyncProvider() with the get time function provided by the RTC library.
PaulS:
Thank you. I did as you suggested re libraries. Download (ZIP) from GitHub imported. Now have a library folder called Time-master, and IDE has ‘Time’ library available.
setTime() - There is no prior variable ‘t’. See full code below.
#include <DS1307RTC.h>
#include <TimeLib.h>
void setup() {
Serial.begin(9600);
setTime(t);
// setTime(11, 29, 28, 28, 4, 20);
}
void loop() {
Serial.print(minute());
Serial.print(" ");
Serial.print(second());
if (second() == 1 || second() == 31) { // to create time markers at 1 and 31 sec
Serial.print("mark");
}
Serial.println();
delay (500);
}
Compiler reports " ‘t’ was not declared in this scope "
the commented line in set-up works ok, and then rest of sketch.
Other suggestions?
aarg:
Thank you. Sorry, but I dont understand required syntax of setSynchProvider() function.
More particularly, I dont understand the