[Arduinolowpower] How it affect millis()

Hello

I am used to work with Arduinolowpower GitHub - arduino-libraries/ArduinoLowPower: Powersave features for SAMD boards and a RTC module.
But now I would like to inactivate RTC. I meanly use RTC to have a exact schdule.
As RTC is now inactivate, I have to use millis() to schedule my next job.

However, it look like something going wrong and I wonder if the board go to sleep, millis() "sleeps" as weel, which would bug my schedule.

Are you aware about Arduino Low Power? Do you have any suggestion and point of view

It is true that millis() will not work in the lowest power modes.

If you need very low power and accurate timing, you could use a 32KHz crystal (and 2 x 18~22pF caps) connected directly to the AVR chip, to wake from sleep every 1 second, for example.

If you need to wake from sleep with a fair degree of accuracy, then I think your obvious choice is an external timing device - the RTC you were using.

However, if you want to sleep for an hour (for example) and don't mind that hour being 55min or 65min, then you can use the watchdog timer to sleep for periods up to 8 seconds. Just keep going back to sleep till the required amount of time has elapsed.

It's not particularly accurate, but it wasn't really designed with this sort of scenario in mind. I have several m328p boards that have been waking hourly for about a month now. They vary in their timing/accuracy of 1 hours worth of 8 second sleeps from 1h +/-30 to 40sec up to 1h +/- 3 or 4 min.

PaulRB:
If you need very low power and accurate timing, you could use a 32KHz crystal (and 2 x 18~22pF caps) connected directly to the AVR chip, to wake from sleep every 1 second, for example.

Could you please explain how " a 32KHz crystal (and 2 x 18~22pF caps) connected directly to the AVR chip" can make AVR awake every second?

alesam:
Could you please explain how " a 32KHz crystal (and 2 x 18~22pF caps) connected directly to the AVR chip" can make AVR awake every second?

Connect the 32.768KHz crystal and caps to an atmega328's clock pins. This means you have to use the internal oscillator, for example at 8MHz. Set timer2 in asynchronous mode to count the pulses from the crystal. Set timer2's pre-scaler to 128. Enable timer2's overflow interrupt. Being an 8 bit timer, it will overflow every 128x256=32768 pulses from the crystal, i.e. every second.

Using SLEEP_MODE_PWR_SAVE and switching off various parts of the chip, you can get down to very low current consumption,<20uA, but timer2 still runs and the overflow interrupt will wake it from sleep every 1s.

PaulRB:
Connect the 32.768KHz crystal and caps to an atmega328's clock pins. This means you have to use the internal oscillator, for example at 8MHz. Set timer2 in asynchronous mode to count the pulses from the crystal. Set timer2's pre-scaler to 128. Enable timer2's overflow interrupt. Being an 8 bit timer, it will overflow every 128x256=32768 pulses from the crystal, i.e. every second.

Thanks, I didn't know about such feature. Unfortunately this way we are limited to 8MHz sys clock.

alesam:
Unfortunately this way we are limited to 8MHz sys clock.

True, but how often is 8MHz too slow and 16MHz is fast enough? Few projects are like that. Also for battery powered circuits, running at 3.3V is often an advantage, which limits AVR chips to 8MHz anyway.