arduino sleep for a month

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

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

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.

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

check this page - Gammon Forum : Electronics : Microprocessors : Power saving techniques for microprocessors - al you ever wanted to know about sleep..

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

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.

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.

Nonsense.

What part? The comment that months have different lengths?

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.

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.

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)

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

update: changed the constants above from L to UL

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.

The code to determine month length is not hard.

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.

PaulS:

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

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.

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.

Iam really sorry..i should hve given a clear description of my project..bascially my barebone arduino would be inserted in a lifter bar..in a grinding mill..using RF modules 433Hz...i would hve to measure the wear and tear of the lifter bar..so basically arduino would wake up say once a month..measure wear and tear by tranmittion and recieving data..by RF modules..and go back to sleep...da concept is dat 4 electrical wires would be inserted in the lifter bar..whenever wear and tear starst to occur wires..would be cut...so i would be ADC Pins..for dat...so bascially i need to wake up my arduino say once a week..longer the better..once a month would be even better..anywayz lets assume wake up once a week..measure wear and tear..and go back to sleep..

Is this grinder mill battery powered?

If the grinder mill plugs into the wall, just use a wall wart to power the Arduino since it's power consumption is so tiny. The Arduino will use a few pennies of wall power per year checking your wires thousands of times per second and never sleeping.

iam not actually handling the mechanical part..ive just joined the company..will ask my boss about wallwart.. all i ve been told is dat through sensors...i ve to detect the wear and tear..including arduino ofcourse...with keeping cost minimum in mind..and since arduino is being powered by battery...i need to minimise power consumption..so dat battery can last for years...anywayz if has given me a project..i gotta finish it..i would be starting making my barebone arduino next week..another guy is handling the code..90percent is done...but he is stuck on sleep modes..etc..do u know any way...if he can..wake up arduino...say once a week or month....

riju:
do u know any way...if he can..wake up arduino...say once a week or month....

For battery power, your choices are simple.

  1. Purchase and connect an RTC to the Arduino. Or,
  2. Sleep for 8 seconds at a time, with 324,000 sleeps in a row between wire checks.

IMHO in an industrial setting with wall power within spitting distance you can plug in to, batteries make no sense.

yeah i was thinking of RTC as well...do i hve to modify my code in any way..so bascially ill use a watch dog timer in my arduino code and then i can use the RTC to give an interrupt to watchdog timer??