Energy saving question and RTC DS3234 Alarms

Hello I need to wake up the arduino every 10 or 15 minutes, I have the DS3234 RTC, but I don't understand how set the alarm,somebody can help me?

Best regards.

Try searching google for the timealarm library.

When you say "wake up the arduino" what state is it in at the time and how does it get in that state ?

Hello, a lot of thanks to all, the problem in the time alarm library is that the arduino is always on, I need that the arduino go to sleep and wake up each 15 minutes to save battery, I think that the DS3234 RTC have internal alarms to do this, but I don't understand how to set up to activate each 15 minutes.

I don't think you can make the DS3234 alarm every 15 minutes. You would have to set an alarm to go off every minute and then, when the alarm does go off, read the minutes register to see if it is 0, 15 , 30 or 45.

Pete

el_supremo:
I don't think you can make the DS3234 alarm every 15 minutes. You would have to set an alarm to go off every minute and then, when the alarm does go off, read the minutes register to see if it is 0, 15 , 30 or 45.

Pete

A lot of thanks Pete, do you know if there is any RTC that I can program to wake up the arduino each 15 minutes? I really need save battery.

Best regards.

I really need save battery.

How much battery are you going to save by not waking up, seeing that the time is not right, and going back to sleep. Those few milli-micro-amps aren't going to matter all that much.

The best description I know about sleep modes of Arduino is here - http://www.gammon.com.au/forum/?id=11497 -

Better change the title of your thread to "Sleep mode (how)" or "energy saving mode question" because that is the question.

The current title reflect a solution (or not :wink:

search for different sleep modes on the page mentioned

I've used the DS3231 (I2C similar to DS3234) to wake up every minute and do a task once every ten minutes. The time spent awake when not performing a task is negligible.

Pete

Hello, the problem is not how to sleep the arduino, the problem is how to wake up each 10 or 15 minutes,if there is not another way i will try the el_supremo solution, waking up each minute :frowning:

Some sleep modes keep the timers active,
These timers can be programmed to trigger an ISR.
This ISR can wake the system when appropriate

robtillaart:
Some sleep modes keep the timers active,
These timers can be programmed to trigger an ISR.
This ISR can wake the system when appropriate

Hello robtillaart, do you have an example? I don't found it.

That info Is on the same page - http://www.gammon.com.au/forum/?id=11497 - search for "Waking from sleep with a timer"

robtillaart:
That info Is on the same page - http://www.gammon.com.au/forum/?id=11497 - search for "Waking from sleep with a timer"

Hello robtillaart, I understand that in the example the arduino is waking up each 8 seconds, the maximum that you can set up a watchdog, but I need wake up each 10 or 15 minutes, how can I do this?

Doesn't most RTc have a little bit of NVRAM too?

  1. Set alarm_count variable, initialize to 1 and record value in RTc NVRAM
  2. Set RTC alarm to 1 minute and trigger an ISR
  3. Put to sleep
  4. A minute later the alarm triggers your ISR
  5. Get the saved value from RTC NVRAM
  6. Check alarm_count
  7. If alarm_count isn't yet 10 then increment by one, save the value, re-set 1 min alarm and go back to sleep
  8. if alarm_count is 10 then execute your action, rest to 1, save the value, set 1 min alarm and go back to sleep
  9. Loop through the wake-up, check, set alarm continuously.

Change a defined value of say alarm_timer and use this for your comparison and you could easily alter the duration from 1 minute to any multiple; 1,5,10,15,28,30,60 etc etf

The time taken to wake up and check the count will be negligible and not have a significant effect if your code is otherwise low load, with the uC otherwise idle in between each action execution.

tack:
Doesn't most RTc have a little bit of NVRAM too?

  1. Set alarm_count variable, initialize to 1 and record value in RTc NVRAM
  2. Set RTC alarm to 1 minute and trigger an ISR
  3. Put to sleep
  4. A minute later the alarm triggers your ISR
  5. Get the saved value from RTC NVRAM
  6. Check alarm_count
  7. If alarm_count isn't yet 10 then increment by one, save the value, re-set 1 min alarm and go back to sleep
  8. if alarm_count is 10 then execute your action, rest to 1, save the value, set 1 min alarm and go back to sleep
  9. Loop through the wake-up, check, set alarm continuously.

Change a defined value of say alarm_timer and use this for your comparison and you could easily alter the duration from 1 minute to any multiple; 1,5,10,15,28,30,60 etc etf

The time taken to wake up and check the count will be negligible and not have a significant effect if your code is otherwise low load, with the uC otherwise idle in between each action execution.

Hello tack, also is a good idea, I will do this if there is not a better solution.

but I need wake up each 10 or 15 minutes, how can I do this?

What you REALLY need to do is measure how many picoAmpHours are used when the Arduino wakes up, checks the time, and sees that it is not time to do something, and goes back to sleep.

How many clock cycles is that going to take? How long, overall, will that take? How much current is that going to take?

Get over it. You WILL have to wake up more often than you think, but that won't shorten your battery life by more than a few seconds over the year that you might get from a decent battery.

Tack's solution is more complicated than mine. All mine does is read the minutes register, make a decision and go back to sleep.
As I and PaulS have said, the "cost" of waking up and going right back to sleep is negligible. You will not be able to measure the difference in current draw.
What you need to do is write some code and try out the sleep/wake up.

Pete

Interesting topic! :slight_smile:
I have a Mega 2560 with an ethernet shield doing some inverter controling on a solar installation.
So obviously, it uses heaps of power - 270ma plus a lcd screen etc
but....during the night it does nothing...wasting that power.
I have installed a RTC on it to reset some counters at midnight for daily data keeping. (KWhours used, peak currents, etc)

anyway, Can I use the RTC in some way to put the whole system to sleep at say, 7pm and wake it up at 6am?