Go Down

Topic: Time and TimeAlarms Libraries – Ask here for help or suggestions (Read 222334 times) previous topic - next topic


Read the time from the RTC. If it is time to do something, do it. If not, don't.

The TimeAlarm class does take care of making sure that the thing to be done is done only once, when the time is right, so you'll need to deal with that, too.
So you say to just compare for example if programedHour==hour(), programmedMinute==minute() etc. then do something?

I will take a look at that

Have you used Alarm.delay() anywhere in your program
Alarm.dealay() not for sure.
However there's a 1ms delay, it's the only delay on the whole code. I have alredy taken care that OneWire doesen't use delays.


I'd also read from the RTC after setting the time, just as a sanity check, to make sure that you have the correct number of values, in the correct order. If you are setting the time to 9:29, but the time that gets read after you do that is 255:255, well, something isn't right.
Do you mean to just this:
Code: [Select]

just after setting the time?
I've tried it, the results are consistent and correct.


Ok, I feel very stupid. It was the freaking 1ms delay.
I knew they could interfer with the code, but come on, it's just 1ms  >:(

Thanks to all of you.

However I'll try to do what @PaulS has said. Because I'm at 96% capacity on my arduino nano...

One last question...
To change the number of alarms I have to modify the .h file:
Code: [Select]
#if defined(__AVR__)
#define dtNBR_ALARMS 6   // max is 255
#define dtNBR_ALARMS 12  // assume non-AVR has more memory

I have to change the number 6 by the number of alarms I want, but what does the second line (the one with the 12) do?


I knew they could interfer with the code, but come on, it's just 1ms
It's not that they interfere with each other. The call to delay() in the Alarm class is the only way that the class has of knowing that ANY time has passed. That method could be called checkForTimePassing(), and maybe it would be more obvious that it needed to be called regularly.

but what does the second line (the one with the 12) do?
It sets the number of alarms on boards that do not have an AVR chip, such as the SAM32 boards. The ARM (non-AVR) boards have, in general, much more memory.
The art of getting good answers lies in asking good questions.


I downloaded   and ran the example in the library below


I keep getting the error,

Compiling 'TimeAlarmExample' for 'Arduino/Genuino Uno'
ccAJvJdt.ltrans0.ltrans.o*: In function main
ccAJvJdt.ltrans0.o*: (.text.startup+0xf8): undefined reference to Alarm

Error linking for board Arduino/Genuino Uno
ccAJvJdt.ltrans0.o*: (.text.startup+0xfa): undefined reference to Alarm
ccAJvJdt.ltrans0.o*: (.text.startup+0xfc): undefined reference to TimeAlarmsClass::delay(unsigned long)
Build failed for project 'TimeAlarmExample'
collect2.exe*: error: ld returned 1 exit status

I have been tinkering with this for the last couple of nights.
Hoping for a solution to get the example working.


Are you sure that you used that example and only that example in the IDE ?
Is there a chance that there was other text in the IDE when you pasted the example code in and/or something in a second tab in the IDE ?
The example is part of the TimeAlarms library installation.  What happens if you load it directly into the IDE from the Examples/TimeAlarms menu ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.


Yes, I loaded the file TimeAlarmExample.ino directly and then attempt to compile it.
I have done this both with the Arduino IDE and Visual Micro.


Have you loaded both the Time and TimeAlarms libraries using the Library Manager of the Arduino IDE?


Yes both libraries were loaded  in the Arduino Ide.

I then tried the following :

I cleared out the contents of the library folder.

Then again downloaded the zip files :

I placed the folder for the TimeAlarms example with the TimeAlarms.ino in the folder in the
C:\Users\mf\Documents\Arduino folder.

I used the Arduino Ide to include the libraries. And indeed the Time-master and TimeAlarms-master are in the  C:\Users\mf\Documents\Arduino\libraries folder.

Finally, I attempted to compile the TimeAlrmExample.ino file
and am still getting the errors.


Then again downloaded the zip files :
Can you load the libraries directly with the library manager?

Sketch>Include Library>Manage Libraries


>Can you load the libraries directly with the library manager?
>Sketch>Include Library>Manage Libraries

It says both are installed already.


Can you run the library example?

Under the File pull down in the ide window can you find and run the library example?


If that runs, can you find the TimeAlarm library example and run it?


The sketch  Examples>Time>TimeSerial will compile.

However the sketch Examples>TimeAlarms>TimeAlaemExample will not compile and  generates the errors as indicated in my previous posts ( i.e. - "cctDYE0I.ltrans0.o:(.text.startup+0x240): undefined reference to `Alarm'")


The sketch  Examples>Time>TimeSerial will compile.
However the sketch Examples>TimeAlarms>TimeAlaemExample will not compile
Do you have v 1.5 of TimeAlarms and see in the example?
Code: [Select]
#include <TimeLib.h>
#include <TimeAlarms.h>

This was a change from v 1.4 with
Code: [Select]

#include <Time.h>
#include <TimeAlarms.h>

Read the postings by Bill Perry (@bperrybap) in this thread for a discussion of the reasons behind this change related to windows,capitalization and the standard c libaray.




Yup, I got it to work.

So, I had installed the Arduino originally on my C: drive. And then later at some point  I also installed the IDE on my D: drive.

Once I uninstalled both, reinstalled on C:, I then reimported the libraries and it complied fine.

I also have Visual Micro installed in Visual Studio 2019.
I was able to compile there fine and download to the board.

It is now working fine for me.

Thank you for your patience and assistance.

Go Up