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