How about we all curse you for choosing a different method of getting the time, that does not expand well to other data that the PC has that might be interesting to the Arduino?
Idiot.
If you just want to set the time, my method is perhaps the most straightforward for doing so.
Or now that you mention it, maybe not.
All right. Here's another method for computing the 10-digit number for setting the time:
This is all client-side, no internet access needed.
Open a spreadsheet program.
In cell A1 goes: =NOW()
In cell A2 goes: 1970-01-01 00:00
In cell A3 goes: =(A1-A2)*86400
Now, look at the number in A3. The part before the decimal point is the number you need.
To update the time, just recalculate the data.
As for "other data the PC has that might be interesting to the Arduino": in what form is this data stored? How you communicate this data to the Arduino, as well as how you have the Arduino handle the data once received, depends very heavily on the format in which you have the data.
Thank you very much for the help. Our group could not figure out this Time library and we discovered that we there were better libraries for our purposes. I.e. we need to run a function every five minutes. We originally thought we needed to use a date and time system but have recently discovered the timer library. Thank you again for your help, it is greatly appreciated.
I believe that my idea will run rather efficiently, but the main advantage is that it handles slight inaccuracies of the oscillator in a very natural (for a microprocessor) way.
Hi there,
Does anyone has a problem like I`m having with Time library? As soon as I do #include <Time.h> and try to verify in any sketch the Arduino IDE throws out compilation error below
/usr/share/arduino/libraries/Time/DateStrings.cpp:18:18: error: variable 'monthStr1' must be const in order to be put into read-only section by means of 'attribute((progmem))'
I got the same errors here with arduino 18, 22 and 1.01. and different Time lib versions.
/usr/share/arduino/libraries/Time/DateStrings.cpp:18:18: error: variable 'monthStr1' must be const in order to be put into read-only section by means of 'attribute((progmem))'
The fix for my debian system was:
go back to gcc-avr version 4.3.5-1 * and
go back to avr-libc version 1.6.8-2 *
Now everything compiles just fine
i updated to gcc-avr 4.7.0-2 and avr-libc 1.8.0-2 which broke compiling TIME libs.
Hello, I’m trying to find out why the Examples in the Time library won’t compile.
I recently downloaded Ardiuno 1.0.1, then followed the directions on the Arduino playground - Time libary page at: Arduino Playground - Time
First, I downloaded the time.zip file, then extracted the folders within it. This yielded one folder named “Time” as well as three folders within this top level “Time” folder. These three folders were named “DS1307RTC”, “Time”, and “TimeAlarms” .
Then I copied the “Time” library into the Arduino “libraries” folder, then started Arduino.exe, and selected TimeSerial.pde from the Examples list. This sketch loaded and I pressed “Verify” and received the error message : “The ‘BYTE’ keyword is no longer supported. “ All of the example sketches failed to compile but had different error messages.
I think I did everything correct, and did it both for the top level “Time” folder and also for the “Time” folder contained within the top level folder. Neither one worked.
Unless I’m doing something wrong, there must be something wrong with the folder structure of the library, but, if so, I am surprised this error is not already well known.
I’m not very experienced with Arduino, so that’s why it is confusing.
Thanks in advance for any information about this problem.
Then I copied the “Time” library into the Arduino “libraries” folder, then started Arduino.exe, and selected TimeSerial.pde from the Examples list. This sketch loaded and I pressed “Verify” and received the error message : “The ‘BYTE’ keyword is no longer supported. “ All of the example sketches failed to compile but had different error messages.
There are two libraries folders - one in your sketch folder and one in the folder where you installed the Arduino IDE. Which one did you copy the Time library to? The one in the Arduino IDE folder is NOT the proper place for user-downloaded libraries.
The BYTE message indicates that the library that contains it has not been updated for 1.0+.
How to update it has been covered many times, many ways, many places.
Pauls: Please indicate at least one or two of the places where update instructions are given. I'm new to this and so don't know where to look. Thanks !!
Is anyone maintaining the time and timealarms libraries? If so, can a version updated to support 1.0.1 be made available? I've searched and can't find it, so if this is already done, please direct me to the latest location. I have modified the version accessible from on the playground page to work wtih 1.0.1 for my own use, but it would cause a lot less confusion if there were an updated version available. If this were done, PAULS wouldn't have to tell quite so many people how to use the search function...
Quarencia:
Is anyone maintaining the time and timealarms libraries? If so, can a version updated to support 1.0.1 be made available?
Good question, I would hope so.
I've searched and can't find it, so if this is already done, please direct me to the latest location. I have modified the version accessible from on the playground page to work wtih 1.0.1 for my own use, but it would cause a lot less confusion if there were an updated version available.
What mods did you make? The only change to the libraries that I found was necessary was that TimeAlarms.cpp needed the following. Strange because the Time and DS1307RTC libraries were updated for 1.0. Several of the examples have other version-related issues, though.
A couple of folks earlier in the thread were wondering why the TimeGPS example didn't seem to be doing anything - I was too, until I spent a little while looking at it this evening. I've written it up over on my blog, but the basic problem is that the sketch invokes the sync provider function before any data has actually been received from the GPS, so there's never going to a suitable date/time at that point. However, because TinyGPS returns a value and the sketch doesn't validate it, it thinks that zero is a valid date value and that gets mapped to 31/12/1999. Job jobbed, date set, nothing more to do here then. Except that this means you don't see anything in the Serial Monitor window except "Waiting for GPS time ...".
I've added in some validation checks to the sketch and updated it to reference the SoftwareSerial libbrary instead of NewSoftSerial and it now works as expected. If anyone is maintaining the Time library and its examples, feel free to roll the code into the download version.
I've been having problems using Time library with watchdog timer. What I see is that at seemingly random times the Arduino gets reset.
I now believe its down to the following code in Time.cpp:
time_t now(){
while( millis() - prevMillis >= 1000){
sysTime++;
prevMillis += 1000;
#ifdef TIME_DRIFT_INFO
sysUnsyncedTime++; // this can be compared to the synced time to measure long term drift
#endif
}
...
in that if the clock drift is negative, the while loop can be quite expensive.
I've replaced it with:
time_t now(){
unsigned long nowMillis = millis();
unsigned long diffMillis = 0;
if (nowMillis > prevMillis) diffMillis = nowMillis - prevMillis;
else diffMillis = prevMillis - nowMillis;
unsigned long diffSecs = diffMillis / 1000;
if (0 != diffSecs)
{
if (nowMillis > prevMillis) {
sysTime += diffSecs;
prevMillis += diffMillis;
#ifdef TIME_DRIFT_INFO
sysUnsyncedTime += diffSecs // this can be compared to the synced time to measure long term drift
#endif
} else {
sysTime -= diffSecs;
prevMillis -= diffMillis;
#ifdef TIME_DRIFT_INFO
sysUnsyncedTime -= diffSecs; // this can be compared to the synced time to measure long term drift
#endif
}
}
...
is this library maintained? Do you agree with this is an issue and with the fix?
regards
Charly
Looks like 'charlya' had a go at fixing it. open up the library file ( Time.cpp ) and find the function 'now()', comment out the first 7 lines ( first code snippet ) and copy in the longer second code.