Time and TimeAlarms Libraries – Ask here for help or suggestions

As much as I dislike repeating myself... read the header files for any lib you use, that is where the function prototypes are... Lots of Good Stuff there

Bob

Excuse me if this has been brought up before, but the TimeAlarms library doesn't have Arduino version check and fails on my Arduino. The Time library does, so I just used it as an example to fix my local TimeAlarms library.

In TimeAlarms.cpp:

#include <WProgram.h>

in Time.cpp:

#if ARDUINO >= 100
#include <Arduino.h> 
#else
#include <WProgram.h> 
#endif

I will be publishing a how-to for my Arduino project and step one for the end user will be to download the Time/TimeAlarm library, so I don't want them to have problems like i did.

Thanks yall for writing this library, I really enjoy it!

Actually the point is of little real interest,. Although it is a good thing that you know how to do it, most who have that issue... Don't come here and post questions.
One thing more the TimeGPS.ino sketch doesn't work. I have one that is working OK but I've not had a chance to post it yet. I did a project that uses a 3.2" 320 X 240 display, a BMP085 barometer and an AMS 2302 hygormeter with TimeGPS for a 'mini' weather station.

Bob

As per below, the following change should be made to TimeAlarms.cpp :

replace:
#include <WProgram.h>
with:
#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif

This change has been made and released in Time.cpp .

2 of the errors I encountered before making this change were:

  • In member function 'void TimeAlarmsClass::delay(long unsigned int)':
  • error: 'millis' was not declared in this scope

Is there somewhere else I should submit this, too?

jaredc:
Excuse me if this has been brought up before, but the TimeAlarms library doesn't have Arduino version check and fails on my Arduino. The Time library does, so I just used it as an example to fix my local TimeAlarms library.

In TimeAlarms.cpp:

#include <WProgram.h>

in Time.cpp:

#if ARDUINO >= 100

#include <Arduino.h>
#else
#include <WProgram.h>
#endif




I will be publishing a how-to for my Arduino project and step one for the end user will be to download the Time/TimeAlarm library, so I don't want them to have problems like i did.

Thanks yall for writing this library, I really enjoy it!

Hi

Not sure if you are aware of this, but alarmRepeat does not work for midnight. E.G.

Alarm.alarmRepeat(0,0,0,myHandler); // This does not call myHandler

I found I had to set the alarm for 1 sec past midnight for it to work.

Alarm.alarmRepeat(0,0,1,myHandler); // This does call myHandler

Guy

Guy-Wittig:
Not sure if you are aware of this, but alarmRepeat does not work for midnight. E.G.

Hi Guy,

0,0,0 is currently ignored by the alarm code. I am traveling at the moment so can't test any code changes, but you are welcome to try the following:

In the updateNextTrigger() function in TimeAlarms.cpp, change :
if( (value != 0) && Mode.isEnabled )
to:
if( Mode.isEnabled ) // remove check for value != 0

Hey all,

I have a question regarding the function time_t now() inside the time library:
Inside this function the Arduino built-in timer ( millis() ) is compared to a last update time of the library.
I wonder what will happen after approx. 50 days of operation when the number returned by millis() has an overflow.

As far as I understood the code, the time will stay at its last update time and will not run anymore.
Did anyone observe such a behaviour or is there a certain function which takes care about such an overflow which I did not recognize?

Thanks,
Thomas

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	
  }

...  

  return sysTime;
}

millis will wrap around after 50-odd days. It doesn't stop, or not run.

If you do subtraction that wrap-around won't matter.

eg.

if (millis () - startTime >= wantedInterval)
  {
  // do something
  }

What will happen if you have the following:
Alarm.alarmRepeat(8,30,0, AlarmA);
Alarm.alarmRepeat(8,30,0, AlarmB);
Alarm.alarmRepeat(8,30,0, AlarmC);

Will AlarmA get executed 1st, and then AlarmB and then AlarmC?

Does the accuracy of the time, depends on other program running, or it has to be idle? In another words, Do I need to add delay(1) or something like that in my loop?

Does the time accuracy changes when used with other libraries like PulsePattern?
http://playground.arduino.cc//Main/PulsePattern

Thank you.
Sia

Alarms for the same time will be called in the order the were scheduled.

The scheduler calls the alarm handler in the Alarm.delay function so this should be called regularly in the sketch. There is a readme file in the download with some more details.
When there are more than one alarm ready to be triggered, the first scheduled alarm is serviced on the next call to Alarm.delay, the next scheduled alarm is serviced on the next call to Alarm.delay and so on.
The accuracy of the servicing depends on how often the Alarm.delay function is called.

I have not used PulsePattern, but if time the code is in the interrupt handler is short, the timing accuracy should not be significantly affected. Why not give it a try. If you print the millis value in the alarm handler you should be able to see if that library is affecting the servicing of the alarms.

I hope that helps.

Have fun!

Thank you Mem. It was very helpful.

I have been successfully use Alarm.timerRepeat(1, DisplayTime) and it seems to work correctly. Showing "millies" is a great idea, thank you. I will add that to my code.

Within my routine, it fetches something from the network, Reading some huge file, and parse and filter what it receives. I have this done every one minute with Alarm.timerRepeat(60, ReadData). The problem is when the data is being read, the DisplayClock does not seem to be executed (Clock stops), for 10~20 seconds. When its done with the ReadData code, it goes back and show the clock every second and the time seems to be correct.

With in ReadData code, I am using Alarm.delay, client.connect and some other functions from Ethernet library.

The PulsePattern works on Timer1. I will give that a try.

Thanks again.

I am a beginner with arduino.
I have a funcioning lcd 20x4 with rtc module after a long time getting the correct libraries to work with arduino1.0.3.
this display the time & date ect but I now need to add alarm functions etc.
the working DS1307library i am using is called DS1307new and my code based on the below that came with library

Scriptname : DS1307_Test.pde
// # Author : Peter Schmelzer, Oliver Kraus
// # Date : 2011-04-08
// # Version : 1.21

I would like to use the alarmtime library and have downloaded the time library from arduino playground but all the programs give compile errors.
I have removed all other libraries to check incase there was any conflicting ones but still does not work.

The above code and library is more complex than the code in the time library and would prefer to use that if possible.

Any help would be appreciated

Once you downloaded the code, it became yours. You need to post YOUR code and YOUR error messages.

Keith, there is code for connecting to a DS1307 RTC provided with the Time library download, its called TimeRTC. Why not use that?

Michael

mem:
Keith, there is code for connecting to a DS1307 RTC provided with the Time library download, its called TimeRTC. Why not use that?

Michael

Well, well. Look who's back. Been a while. Life treating you well, I hope.

PaulS:
Well, well. Look who's back. Been a while. Life treating you well, I hope.

Hi Paul, its good to be back.
I have been busy with all kinds of interesting projects. Still am, but will try to hang out here as much as possible.

Michael

mem:
Keith, there is code for connecting to a DS1307 RTC provided with the Time library download, its called TimeRTC. Why not use that?

Michael

Yes I have tried that but I can´t get any of the code to work of the official time library download, any ideas

just to illustrate I have just opened TimeRTC from examples/time/time/examples and tried to compile it. I have not touched this code. I just gave the other code so you were aware of what was working, I can post the whole code but becomes rather long.
I'm sure the solution if something simple but can't get it.
It seems to me it is not picking up the library but yet it is in the right place and in shown in examples.. thanks for any help. the errors in compiling shown below.

TimeRTC.pde: In function 'void setup()':
TimeRTC:13: error: 'RTC' was not declared in this scope
TimeRTC:13: error: 'setSyncProvider' was not declared in this scope
TimeRTC:14: error: 'timeStatus' was not declared in this scope
TimeRTC:14: error: 'timeSet' was not declared in this scope
TimeRTC.pde: In function 'void digitalClockDisplay()':
TimeRTC:28: error: 'hour' was not declared in this scope
TimeRTC:29: error: 'minute' was not declared in this scope
TimeRTC:30: error: 'second' was not declared in this scope
TimeRTC:32: error: 'day' was not declared in this scope
TimeRTC:34: error: 'month' was not declared in this scope
TimeRTC:36: error: 'year' was not declared in this scope

It looks like the libraries are not being found.
Make sure you have installed DS1307RTC in the Arduino libraries folder.

The Time.zip file is structured so you can copy the three folders (Time, TimeAlarms, and DS130RTC) into the Arduino Libraries folder.

Yes that what it seems like to me yet all the folders were unzipped correctly in the library folder.
I've taken the screen shot to show