sleeping and timing acuraccy

hi all
making an automated dispenser with a mega 2560
runs pumps for a few seconds in set patterns then waits for a period (somewhere in the region of 20 mins to 5h)

everything is working great but as its battery powered i need to reduce power consumption

im planning on putting it into sleep mode of some sort.

what options do i have to wake the arduino up after x time?

of those options what are the accuracy of them?

when people quote accuracy of 30mins +/- 1 mins. will it likely always be 31 or 29 for a given setup or will it vary each day?

More info, please......
What other stuff is used in the project? Valves, motors.....
Post code, using code tags, and wiring diagram here in the topic.

Consider a RTC. If accuracy is not critical, a DS1307, a DS3231 if it is critical from day to day.

Railroader:
More info, please......
What other stuff is used in the project? Valves, motors.....
Post code, using code tags, and wiring diagram here in the topic.

as much as i appreciate your interest in the project it's not really that interesting! i just need to put the arduino to sleep and how accurately it can wake up

(i don't have wiring diagrams or the code available on this system)

Quote from: Paul__B Sat Jan 02 2021 00:26:55 GMT+0000 (Greenwich Mean Time)

Consider a RTC. If accuracy is not critical, a DS1307, a DS3231 if it is critical from day to day.

i have an old RTC module. i'd really rather not have to wire it in and set it up though.

Iv also got no idea what that would gain me to make the consideration.

As You wish. I step back.
Personally I think that saving energy calls for an overlook of the hole project. Why spend time saving some little energy in the controller if, maybe, other components use a majority of the energy?

Tutorial on sleep modes and power saving.

as much as i appreciate your interest in the project it's not really that interesting! i just need to put the arduino to sleep and how accurately it can wake up

I think you need to decide the acceptable tolerance on sleep time. The obvious free option is to use the internal watchdog timer which will sleep for up to 8 seconds at a time. Multiple sleep cycles are used to reach the desired overall sleep time. However, the watchdog timer was not designed for this scenario in mind. Expect an accuracy of around +/- 3 to 5 minutes per hour. And that will vary between processors and with ambient temperature.

Otherwise you are looking at an external device - i.e. an RTC.

Do all sleep modes have a max time of 8 seconds?

The accuracy you quote there with the internal watchdog. Is that utalising the crystal oscillator?

I don't really have an acceptable tolerance at this time. There's no firm requirement. I need to see what power draw and accuracy options I have so me and the guy I'm working with can weight up the pros and cons. No binary desisicions in the real world unfortunately.

So option 1 is Rtc.
Very accurate and very low power consumption. But a load more effort as iv never used one befor

Option 2 is internal watchdog. Not very accurate. quite low power consumption but very easy to implement

According to the user guides online there should be higher power draw more accurate options.

But the accuracy and power isn't stated

The sleep modes and the 8 second time period are not related. You can put the processor to sleep for many days and get it to wake up as a result of an external event (interrupt).

The 8 seconds maximum is a function of the watchdog timer module (I think it's actually 8.192 seconds under perfect conditions). The watchdog timer uses its own 128kHz oscillator (unrelated to the crystal oscillator) which is divided down to get the required timeout period up to the maximum of 8 seconds.

An RTC isn't a complicated beast to implement. You can buy a module off the shelf. The DS3231 based modules are the most accurate of the RTCs in general use.

In a recent discussion, one of the contributors mentioned that they had used a 32.768kHz watch crystal as an external clock source fed to one of the on-board timers to count time. This method obviously needs a processor more "awake" than the deep sleep mode, so consumes more power.

Have a look at this article as it discusses low power modes. Another excellent read is The Cave Pearl Project.

The DS3231 RTC has an alarm function that can be set to wake up the Mega from deep sleep. Connecting it is pretty simple (5 wires) and there are libraries that help with the programming. What’s the old module you mentioned you already have?

The popular module with a DS3231 chip is labeled ZS-042. It requires a couple modifications, but they are just removing things with a soldering iron, so not really a problem.

Yes that's what I have.

I have to remove a bit to stop it charging the battery as far as I'm aware.

What I was hopeing was someone would tell me how I could keep the occilator circit running and go into a lower power state. But from my own research it seems thease options are not very well used (and therefore harder to replicate myself) . I'll dig out a battery for the rtc tomorrow

The other mod is to remove the LED. It doesn't hurt anything, but just wastes power.