Efficient Battery Timer; Onboard Crystal Resonator

Hi Everybody!

I need some guidance for achieving a low-power, but exact 24-hour timer function, please!

For example:
The Arduino turns on a devise for 6 hours, then off for 18 hours, repeat cycle.
or
The Arduino turns on a devise for 6 hours, off for 5 hours, on for 2 hours, then off for 11 hours, repeat cycle.

Is that timer function possible with the following approach:
Set the output pin high,
Put the Arduino board to sleep,
After 6 hours, the crystal resonator wakes up the Arduino board,
Set the output pin low,
Put the Arduino board to sleep,
After 18 hours, the crystal resonator wakes up the Arduino board,
Repeat cycle.

I can turn a devise on and off using the delay function, but I think that doesn't use the crystal resonator, and using the delay function requires the Arduino board to stay powered up and consume a lot of power.

I've read up on the various sleep modes, timers, and the watchdog function, but everything seems to not quite be able to do the simple timer function I need. Maybe I've misunderstood something. (It doesn't help my research that my task is named the same thing (timer function) as one of the features of an AVR chip.)

I'm using a Digispark Pro (Attiny167) because that's the most basic Arduino board I've found that includes a crystal resonator. The crystal resonator is important because I'm requiring very long time spans (hours) of "on" or "off," and I want minimal drift.

That's only a word. What exactness is really motivated? Tell why, tell more.
It's very easy to ask for very high precision but that can cost a lot.
Chrystal resonator will not give that. A Chrystal oscillator could be thinkable.
Just study the current consumption for such a device and compare it with conventional RTC in power down mode.

These Attiny dev boards from Microchip are pretty good. This one you can solder a 32K crystal and it has built-in RTC than can give you sleep times up to 18 hrs.

https://www.microchip.com/en-us/development-tool/EV50J96A

Sorry, here's what I meant by my word choice of "exact":

I'm hoping to achieve drift measured in seconds (at most) instead of minutes.

As I understand programmable chip technology, the internal timing RC tank circuit in a chip has susceptibilities to loose tolerances and temperature changes that cause problems for long time measurements (hours). This same phenomenon is why 555 chips are inappropriate for generating a frequency with a period of hours. They will drift from their original start time fairly quickly. The amount of drift from an RC oscillator is problematic for my project. Using a crystal resonator for the oscillator circuit significantly improves timing as it's much less susceptible to fluctuations in temperature.

I suggest using an RTC. That gives You a cheap, often temperature compensated, "oscillator".

Is there no way to take advantage of the crystal already on the Arduino board instead of using an RTC? I'm trying to avoid the additional component of an RTC.

Also, is it possible to use my suggested approach of automatically putting the Arduino to sleep for various amounts of time, waking it up to flip a switch, then putting it back to sleep? The closest to that I've found is putting the Arduino to sleep until it gets woken up by an external interrupt, at which point it resets. That's close, but doesn't achieve the desired task.

It looks like the board you linked to in #1 has a 16mhz crystal oscillator, rather than a less accurate resonator.

I don't think you can use the very low power modes as they use the watchdog timer to interrupt the "deep sleep" mode of the cpu, but the watchdog timer isn't that accurate (it's not meant to be).

I assume that you are wanting low power because you are going to run your project off batteries? Do you have an idea of the runtime you want to achieve on batteries? A week, a month?

"Exact" can be very costly. Does it matter to your project if the time drifts by 1sec per day, 10sec per day?

If you can put some ballpark figures on those, it will guide you towards a possible solution.

Not if you want to employ sleep mode.

Apparently the secondary oscillator with the 32 kHz crystal, periodically waking to accumulate overflow counts, may be appropriate.

Otherwise just use a RTC.