-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set alarm every X minutes #13
Comments
The only way is using a counter. |
You can use ALARM_MATCH_MINUTE_HOUR. |
thanks ;) I think I like your approach better than what I was doing with the counter. The only thing is, isn't it more simple to use just the minutes? here is the code that I'm trying at the moment, it seems to work. Basically I'm declaring the global variables, then I initialize them in the setup with
then I use this lines both in setup and in loop functions:
The whole code: [...]
int interval = 2;
DateTime time;
int mins;
[...]
void setup() {
[...]
time = Clock.read();
mins = time.Minute;
mins = mins + interval;
if (mins >= 60) mins = mins - 60;
time.Minute = mins;
Clock.setAlarm(time, DS3231_Simple::ALARM_MATCH_MINUTE);
[...]
}
void loop()
{
if(Clock.checkAlarms())
{
[...]
mins = mins + interval;
if (mins >= 60) mins = mins - 60;
time.Minute = mins;
Clock.setAlarm(time, DS3231_Simple::ALARM_MATCH_MINUTE);
[...]
}
} |
Well, that is better than my idea (of course if the interval is less than 59 minutes) |
two heads are better than one ;) I'll read the article too, thanks ;) |
Thanks, this is exactly what I'm looking for! Just a note for future visitors/users, |
Hi,
thanks for your library, it's the one that I'm using ;) there's just a couple of things I feel the need for.
I understand I can I can set these alarms:
ALARM_EVERY_MINUTE [fires every minute]
ALARM_MATCH_SECOND [fires every minute at a specified second]
ALARM_HOURLY [fires every minute]
ALARM_MATCH_MINUTE [fires every hour at a specified minute]
But how can I, for example, set an alarm every 5 minutes, 10 minutes, 15 minutes or 30 minutes? I'm using your library for a datalogger, and I would like to increase the logging interval. I'm using a counter for the moment, but hopefully there's a better way.
Thanks
P.S.
opening a separate discussion for the second question ;)
The text was updated successfully, but these errors were encountered: