Offline
Sr. Member
Karma: 2
Posts: 354
|
 |
« on: January 18, 2013, 09:35:29 am » |
Good Afternoon :-),
I'd like to implement a timer for schedule operation with arduino using DS1307, well do you know where I can start ?
my intention is store the timer inside arduino eeprom and check each time if the time is equal to or greather than the time set,
my focus is do something easy to do,
Thanks Andrea
|
|
|
|
« Last Edit: February 04, 2013, 05:41:26 am by gnusso »
|
Logged
|
|
|
|
|
Temple, Texas
Offline
Sr. Member
Karma: 14
Posts: 354
|
 |
« Reply #1 on: January 18, 2013, 09:53:06 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #2 on: January 18, 2013, 09:58:14 am » |
Thanks John :-)
Andrea
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #3 on: January 22, 2013, 02:50:10 am » |
Good Morning John, looking the library what I've understood is that is possible set timer during the day,
for example i'd like to set timer for tomoroww or tuesday or in another day choose is possible to do that ?
like this:
start timer: 22/01/2013 15:45 stop timer: 24/01/2013 20:30
thanks for the information, gnux
|
|
|
|
|
Logged
|
|
|
|
|
East Anglia (UK)
Online
Edison Member
Karma: 47
Posts: 1406
May all of your blinks be without delay
|
 |
« Reply #4 on: January 22, 2013, 03:14:09 am » |
Using TimeAlarms you can set an alarm to trigger any date and time. When that alarm is triggered the the actions that you specify will be carried out. This could include setting the alarm to trigger again.
From the readme file
"If you want to trigger once at a specified date and time you can use the trigger Once() method: Alarm. triggerOnce(time_t value, explicitAlarm); // value specifies a date and time (See the makeTime() method in the Time library to convert dates and times into time_t)"
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #5 on: January 22, 2013, 06:25:05 am » |
Thanks, if i not understood bad please correct me if i wrong
Alarm.timerOnce(time_t value, explicitAlarm);
time_t_value --> is my date 22/01/2013 12:23 --> using the excel conversion is in number 41296.52
well at this point should conver my date in number and how can i do for do it ?
Thanks, gnux
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #6 on: January 22, 2013, 06:46:49 am » |
I've looked into the library ...
but Im not able to use an a pratical example for doing the coversion ...
could you help kindly me ?
Thanks, gnux
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #7 on: January 22, 2013, 10:11:58 am » |
So i've did several try but i don't undestand boa use the function, can some Give me an example ... Kindly ? :-) thx gnux
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #8 on: January 22, 2013, 11:14:47 am » |
Hi, Could be something like that ? for example : 22/01/2013 17:12:00
tm.Year = 2013; tm.Month = 01; tm.Day = 22; tm.Hour = 17; tm.Minute = 12; tm.Second = 00; Alarm.timerOnce(makeTime(tm), OnceOnly) ;
Thanks Gnux
|
|
|
|
|
Logged
|
|
|
|
|
Temple, Texas
Offline
Sr. Member
Karma: 14
Posts: 354
|
 |
« Reply #9 on: January 22, 2013, 12:27:36 pm » |
Yes you are almost there!  In fact, instead of typing that into a forum post and hitting "Submit", You could type it into an empty sketch (surrounded by setup(){...}) and hit "Verify". Any error messages might guide you the rest of the way. It is often faster than the forum too!  Cheers, John
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #10 on: January 22, 2013, 01:47:14 pm » |
Yes, I'm completely agree with you :-) but today I was at work without time for try to do it :-) ...
and then I've Im waiting a input for start in right direction ;-) only that :-) ... in the meantime the unique things that I was able to do was looking inside the forum that was another similar topic ...
gnux
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #11 on: January 22, 2013, 01:59:57 pm » |
For example I've did this simply sketch: #include <Time.h> #include <TimeAlarms.h>
void setup() { Serial.begin(9600); setTime(8,29,0,1,1,11); // set time to Saturday 8:29:00am Jan 1 2011
tm.Year = 2011; tm.Month = 01; tm.Day = 01; tm.Hour = 8; tm.Minute = 31; tm.Second = 00; Alarm.timerOnce(makeTime(tm), OnceOnly) ; // Alarm.timerRepeat(15, Repeats); // timer for every 15 seconds // called once after 10 seconds }
void loop(){ digitalClockDisplay(); Alarm.delay(1000); // wait one second between clock display }
// functions to be called when an alarm triggers:
void OnceOnly(){ Serial.println("This timer only triggers once"); }
void digitalClockDisplay() { // digital clock display of the time Serial.print(hour()); printDigits(minute()); printDigits(second()); Serial.println(); }
void printDigits(int digits) { Serial.print(":"); if(digits < 10) Serial.print('0'); Serial.print(digits); }
I received back the error : 'Tm was not declare in this scope' ... Then I've declared the type of variable looking the library ... but understanding was that tm should be a method of timer library correct and is not necessary to declare but just call ... So declaring the variable static tmElements_t tm; the error during the compile is disappeared but the condition is never verified ... where i wrong ? I come back after 10 hours of work thanks for to be patient ... thx to all for the support, gnux
|
|
|
|
« Last Edit: January 22, 2013, 02:17:50 pm by gnusso »
|
Logged
|
|
|
|
|
Temple, Texas
Offline
Sr. Member
Karma: 14
Posts: 354
|
 |
« Reply #12 on: January 22, 2013, 02:21:28 pm » |
For example I've did this simply sketch: ... I received back the error : 'Tm was not declare in this scope' ... ...
This is excellent. The message is telling you very specifically, that you are trying to use a variable which has not been declared, or at least not declared in an appropriate place. "Declared" means like this: int g; // variable g is declared here
void loop(){ int loc; //variable loc is declared here
g = g + 1; // variable g is used here
loc = 7; // variable loc is used here int i=43; // variable i is both declared and used here i= i - 1; // }
So what your message is saying is that you're trying to use a variable called "tm" and there is none. For your code it is very simple to fix: ... TimeElements tm; // declare variable tm here tm.Year = 2011; // begin using variable tm here tm.Month = 01; ...
Than i shouldn't received this kind of issues. ... where i wrong ?
I can't say that that is the only problem with your sketch, but its a start... Cheers, John
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #13 on: January 22, 2013, 03:32:19 pm » |
Ho thx for the advise :-) so i ve see that was miss the declaration infact i ve tried to declare in this way
static tmElements_t tm;
And the compile was ok
But the conditi in was never verified , so ill try your suggest and ill let you know thanks gnux
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #14 on: January 22, 2013, 03:51:24 pm » |
So, also changing the the declaration now i didn't have the errors from the compiler ...
but the condition is never true ...
and I don't understand why ... I've also did a Serial.println of makeTime(tm) but the number that I've tell me nothing if didn't have another function that convert back the value ...
:-( so now I'll let's go to bed because I'm completely fuse ...
thanks for the support, gnux
|
|
|
|
|
Logged
|
|
|
|
|
|