SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By Pascal1966
#194518
Hello!
I am using the below library and instructions in order to put my UNO on sleep mode when it does not have anything to do for a while:
#include <LowPower.h>
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
Problem: I am also using millis() to keep track of time, and this method seems to reset millis() to zero every time it is used, so my program does not work any more...
Is there another clock that is accessible and not turned off or reset by this method? how to use it?
eventually I want to migrate to a Pro Mini, so the solution should work there, too.
Regards,
Pascal.
By Valen
#194541
Please be more specific in where you got the library from. Google says there are more than one.
By Valen
#194544
Either way, in Power down mode the Timer0 is also turned off, or at least prevented from updating the millis since the interupts don't work for that timer. You could try the Idle mode instead and not turn off the Timer0.

Recoding the Arduino framework to use another timer instead is not possible. I mean, feel free to make your own fork of the Arduino github page and tinker with it. But it is best to leave this to the pros.https://github.com/arduino/Arduino

I think the best bet is to use an external Realtime-clock chip and keep track of time that way.
By Pascal1966
#194770
Thanks for the responses.
I indeed decided to use an external clock (RTC) in order to wake up my Pro-Mini every minute or hour depending on the application.
I am a bit disappointed to still need ~7mA when in sleep mode. Added to that are the 3mA of the RTC, but that's another problem.
7mA includes the power LED which I have not yet removed (I wish I did not have to, not sure how much i'd save...)

My question is:
Is there a 'deeper' sleep mode than the one I am using below?

I am using:
#include <DS3232RTC.h>
#include <TimeLib.h>
#include <avr/sleep.h>

and:

attach_RTC_interupt(); delay(100);
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sleep_mode(); // here the CPu is actually put to sleep. The program continues from here after waking up
sleep_disable(); // first thing after waking from sleep: disable sleep.
detach_RTC_interupt();

Regards,
Pascal.
By Valen
#194771
Trying to power save in deeper sleep with an Arduino Uno board is just not going to be. There are too many other parts in the schematic that also consume power no matter which sleep mode you choose. The power led being one of them. If you really want to experiment with that then you should make a barebones minimal setup on a breadboard. Just the Atmega328 chip, a crystal with load capacitors, some capacitors to buffer the power input pin, a pull-up to the reset pin and a USB to serial converter. Plenty of examples of that on youtube. There is even a tutorial here from sparkfun somewhere on the learing part of the site. I can't be bothered to find it. I need to sleep.
By Pascal1966
#194775
Thanks for reminding me that, Valen. You are perfectly right, I looked it up in the mean time and I read exactly that: use a bare-bone.
By the way the 7mA I mentioned is not with a UNO but a Pro-Mini. A UNO would be more in the ~30-40mA even in sleep mode, due as you said to all the stuff that is running around the CPu.
The Mini can be reduced further by removing the power LED and also the voltage regulator.
Regards.