Pages: [1] 2   Go Down
Author Topic: arduino sleep for a month  (Read 1129 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Iam working on a project where by using power mode techniques...i ve to minimize my power in my arduino...obviously i have to build a barebone arduino..which iam almost finished making..iam working on my code..i just need to ask is there any way..i can make my barebone arduino sleep for a month..wake up once a month..check and recive data....den go black to sleep..
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24433
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You're going to need a device that provides an external interrupt once a month to wake the AVR up.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46224
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
is there any way..i can make my barebone arduino sleep for a month..wake up once a month..check and recive data....den go black to sleep..
No. The longest you can sleep is 8 seconds (IIRC). But you don't need to do anything when awake except check to see if enough 8 second intervals has elapsed. Incrementing a counter takes nearly no time and no power. Checking the counter against a known value takes little time and little power.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24433
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can sleep as long as you want, but the slowest watchdog time out is very roughly eight seconds.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12483
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

check this page - http://www.gammon.com.au/forum/?id=11497 - al you ever wanted to know about sleep..
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Edison Member
*
Karma: 57
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A library is made to use sleeping over and over again, until a certain time is reached.
http://code.google.com/p/narcoleptic/
If you want exactly a month, you should add an RTC module (Real Time Clock).

The Narcoleptic.delay() uses an integer. That makes it usefull up to 32 seconds.

However the library is easy to understand. It should not be hard to add a Narcoleptic.delayDays( int days).
« Last Edit: September 15, 2013, 01:06:58 pm by Erdin » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46224
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If you want exactly a month, you should add an RTC module (Real Time Clock).
Good point about an RTC. Using the watchdog timer to sleep 8 seconds at a time would work, but the Arduino won't do it's thing exactly once a month, since months have different lengths - 28, 29, 30, or 31 days.
Logged

Offline Offline
Sr. Member
****
Karma: 19
Posts: 486
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Using the watchdog timer to sleep 8 seconds at a time would work, but the Arduino won't do it's thing exactly once a month, since months have different lengths - 28, 29, 30, or 31 days.

Nonsense.  The code to determine month length is not hard.  There are several ways to do it, and none of them are very hard.

The RTC will need additional power.  Depending on how exact you need to be, you might be able to calibrate the 8 second counter to be close enough.
« Last Edit: September 17, 2013, 02:19:34 pm by TanHadron » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46224
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Nonsense.
What part? The comment that months have different lengths?

Quote
The code to determine month length is not hard.
My Arduino shows millis() returning 1,567,312. What month is it? Without a lot more information than the Arduino has, calculating the time, the date, the month, etc. is impossible. You're the one spouting nonsense.

Quote
There are several ways to do it, and none of them are very hard.
Show ONE. Remember, all you know is how long the Arduino has been running. And, you might not even know that, because you might not know how many times the counter has rolled over.

I'm waiting.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12483
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The Narcoleptic.delay() uses an integer. That makes it usefull up to 32 seconds.

However the library is easy to understand. It should not be hard to add a Narcoleptic.delayDays( int days).

I posted an issue to use an unsigned long for the delay() method, making its range larger (49.7.. days) and make it interface match the normal delay()  (not the behavior)
- https://code.google.com/p/narcoleptic/issues/detail?id=4 -

a days delay becomes
delay(86400UL * 1000UL);   // seconds/day * millis/second

update: changed the constants above from L to UL
« Last Edit: September 16, 2013, 02:11:52 pm by robtillaart » Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Edison Member
*
Karma: 57
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Very good robtillaart.

I write my constants in a way that I can understand it.

// delay for a day 1000 for seconds, 60 for minutes, 60 for hours, 24 for a day.
delay( 1000UL * 60UL * 60UL * 24UL);

Looking at the other issues of narcoleptic, I would like to fork it to a page in the Playground.
The issue that it is not working on a ATmega8 is obvious, that old chip has no WatchDog interrupt.
« Last Edit: September 16, 2013, 09:37:38 am by Erdin » Logged

Idaho, US
Offline Offline
God Member
*****
Karma: 19
Posts: 859
Special User
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The code to determine month length is not hard.
Quote
My Arduino shows millis() returning 1,567,312. What month is it?
Even without an RTC, the compiler macros __DATE__ and __TIME__ can be placed in a sketch. Make this your "epoch". As long as you leave the Arduino powered on after compiling and uploading the sketch, it can know what month it is (subject to clock drift, of course).

The number of millis() rollovers that have occurred can be stored in a variable to add appropriate offsets to "now" from the epoch.
Logged

Sydney, Australia
Offline Offline
Sr. Member
****
Karma: 6
Posts: 396
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If you want exactly a month, you should add an RTC module (Real Time Clock).
Good point about an RTC. Using the watchdog timer to sleep 8 seconds at a time would work, but the Arduino won't do it's thing exactly once a month, since months have different lengths - 28, 29, 30, or 31 days.

Couldn't he use a DS3232 on battery and set the alarm function on that chip to wake the arduino, take his measurement and then set the alarm for another month ?

Obviously the OP has not told us if he means the same day every month, 30 days apart, the last sunday of the month etc etc

Craig


EDIT: Sorry just realised that the DS3232 only has a time of day alarm - still simple enough to use it to wake the arduino once per day and keep a counter of number of days
« Last Edit: September 16, 2013, 05:46:45 pm by craigcurtin » Logged

Offline Offline
Edison Member
*
Karma: 6
Posts: leet
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code to determine the number of days each month is easy.  All you need to know is which month it is currently.

Accuracy is not an issue because Narcoleptic can be calibrated, but not as accurately as the Uno clock when it is running.

It takes little power to wake every 8s for 10ms.
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Sr. Member
****
Karma: 19
Posts: 486
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, PaulS, the only nonsense is that the Arduino won't do its thing exactly once a month.  It isn't hard to program around the varying month lengths.

And yes, it helps to know which month it is, but that isn't absolutely necessary.  The only real advantages that gives us are the ability to choose exactly when during the month the Arduino does its thing, and to make it easier to work around the boundary conditions.

One easy way is to divide a year by 12, and use that for your month length.  Then avoid the boundaries by firing the event sometime in the middle of the month, like today, for instance.  The exact point at which the event fires relative to the start of the month will vary a few days, but it will sync back up every 400 years or so if you do it right.

You are absolutely correct in that you have to know SOMETHING about which month it is or where we are in the current month, or the event might fire twice in some months and not fire at all in other months.  But then again that's not hard to accomplish.
Logged

Pages: [1] 2   Go Up
Jump to: