Sleeping with watchdog


I am trying to make my arduino goes to sleep. I need arduino to be sleeping for a long time. My first idea was keeping it slept all day except for one hour or something like that. But now I think maybe a better idea is awake it every 8 seconds (I think it is the longest time watchdog can handle).

My program has to start, reads 2 or 3 sensors and sends data by xbee. After that, goes to sleep until next time.

I have tried to make it sleeping during 10 seconds and try to get it awake alone but I can’t. I think maybe watchdog can help me with this. I put it to sleep after send info, it will restart alone after 8 seconds and repeat the process.

I found this post:,78146.msg592562.html#msg592562

My question is about if it is a good solution for my project. And if I should add something more or changing something in that code. The node which receives data will stay allways awake so there is no problem about when to send data. Which sleep mode can I use with it? Can I use the most power saving? Watchdog will keep working?

I think, with this solution, I can send to sleep xbee too before sleeping arduino. Then before sending data, I wake up it.

I've done a lot of stuff about power saving here:

I suggest using the watchdog to sleep for 8 seconds, in a loop, so it wakes, goes back to sleep etc.

You can save extra power by running at a lower frequency (and thus the 8 seconds would become longer) or a lower battery voltage.

Thanks! I will read your link.

Reduce frequency will affect to arduino? I guess no, but I am not sure. I mean talking about its life. I supose it will work slowly.

Well if you operate at 8 MHz rather than 16 MHz, then the watchdog will be 16 seconds and not 8 (twice as long). You can operate at 1 MHz and then you get 16 times as long.

It won't affect its life. Of course you need to compensate if you are doing something like serial comms, but that can be done.

Running off 3.3V rather than 5V reduces power consumption to 10% according to the figures on that page.

I am trying the code I post in my link. I have a question. It says that time is 8 sec. But it uses "1".... Is that correct? I read about using 1 sec problem in older arduinos. I have a freeduino 1.22 (duemilanove bootloader).

Where can I foud information about compensate operation frequency for serial comms? I need to send data by xbee.

I guess this willl work for arduino fio too. I am doing my test in freeduino but final program will be in Fio.

I changed it to 3. It seems to work. Goes to sleep and after 8 seconds more or less, it starts again.

I have a question related to consume. I read about have no pins floating in order to reduce consume. How can I do that? I will use 3 analog pins for 3 sensors and just one digital pin to set xbee to sleep or wake it up. What do I have with them? also the unused pins?

My tests appeared to indicate that setting unused pins to output and low had a low current consumption. Or just tie them low with pull-down resistors (eg. 10K). Anything to stop them "floating" and making readings of nearby noise.

But it uses "1".... Is that correct?

I changed it to 3. It seems to work

I can't answer questions like that unless you specify what "it" is.

Sorry.I use to think that everybody read my mind :blush:
I was talking about this line:

#define sleepTime  1                       //number of 8 second sleep cycles

You talked about use low voltage. I liked it. I will try to use it too. But you said: "Of course you need to compensate if you are doing something like serial comms, but that can be done." What can be done? How can I change voltage during execution or compensate it to use xbee? My xbee are series 1 pro. I have read that Pro has a higher consume... Maybe reducing voltage will reduce network area. I don't know if xbee can operate less than 3,3 v. I will check it.

I actually said:

if you operate at 8 MHz rather than 16 MHz … you need to compensate if you are doing something like serial comms …

If you run at half speed, and don’t “tell” the sketch, then a delay (1000) will delay for 2 seconds and not 1 second. That’s what I meant.

It’s nothing to do with running at lower voltages.

If you drop the voltage to 3.3V you can still run at 16 MHz. If you go much lower you need to also reduce the speed. There is a table on the page I linked to which shows that.

I don’t know about the Xbee and its coverage, regarding voltage. The datasheet should show that.

oh, ok I see. I understood that I need to change voltage or something like that when talking with xbee.

I think, now I have all understood. I will try to implement this solution during next week. If I complete it, I will post here. Or also if I have more question.

Thanks indeed, you helped me a lot.

I forgot to ask you something important. Do I need a voltage regulator if I reduce voltage? I mean, usb provides 5 volts, if I reduce voltage to 3.3 … Same happends with batteries I think. Something like 7805 for less voltage or so. I mean, I shouldn’t connect arduino to usb or bateries directly, should I?

If you want to run off a lower voltage, then some sort of regulation will be required. Eg. a 3.3V regulator, or a zener diode with appropriate resistor. I think I have even heard of people putting a couple of “ordinary” diodes in series, since a diode will generally have a 0.7V voltage drop across it, two would drop 1.4V, which subtracted from a steady 5V from the USB would give 3.6V.

Ok. Then I will check which voltage I use and after I will look for the apropiated regulator. Thanks!