Go Down

Topic: arduino sleep for a month (Read 1 time) previous topic - next topic

riju

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

AWOL

You're going to need a device that provides an external interrupt once a month to wake the AVR up.
"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.

PaulS

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.

AWOL

You can sleep as long as you want, but the slowest watchdog time out is very roughly eight seconds.
"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.

robtillaart

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

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

Erdin

#5
Sep 15, 2013, 07:54 pm Last Edit: Sep 15, 2013, 08:06 pm by Erdin Reason: 1
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).

PaulS

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.

TanHadron

#7
Sep 16, 2013, 02:26 am Last Edit: Sep 17, 2013, 09:19 pm by TanHadron Reason: 1
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.

PaulS

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.

robtillaart

#9
Sep 16, 2013, 01:52 pm Last Edit: Sep 16, 2013, 09:11 pm by robtillaart Reason: 1
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
Rob Tillaart

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

Erdin

#10
Sep 16, 2013, 04:32 pm Last Edit: Sep 16, 2013, 04:37 pm by Erdin Reason: 1
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.

tylernt

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.

craigcurtin

#12
Sep 17, 2013, 12:38 am Last Edit: Sep 17, 2013, 12:46 am by craigcurtin Reason: 1

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

sbright33

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.
If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

TanHadron

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.

Go Up