Go Down

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

MBC99

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.


MBC99

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]
Serial.print(hour());
  Serial.print("\t");
  Serial.print(minute());
  Serial.print("\t");
  Serial.println(second());


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

MBC99

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
#else
#define dtNBR_ALARMS 12  // assume non-AVR has more memory
#endif


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?

PaulS

Quote
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.

Quote
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.

mag63

I downloaded   and ran the example in the library below

https://github.com/PaulStoffregen/TimeAlarms

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.

UKHeliBob

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.

mag63

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.

cattledog

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


mag63

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 :
   https://github.com/PaulStoffregen/TimeAlarms
   https://github.com/PaulStoffregen/Time

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.



cattledog

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

Sketch>Include Library>Manage Libraries

mag63

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

It says both are installed already.


cattledog

Can you run the library example?

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

Examples>Time>TimeSerial

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

mag63

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'")


cattledog

Quote
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.

https://forum.arduino.cc/index.php?topic=451360.msg3104590#msg3104590

https://forum.arduino.cc/index.php?topic=451360.0



mag63


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