Arduino Time signal base

Hello everyone:

I'm running some code on an attiny that needs to have a time base. The chips is too small in terms of pins or memory to run code for an RTC.

Was wondering if there is a way to, for example, run the time library and set the values by polling a pin or similar. The idea was to sync the time on the occurrence of an alarm set on the RTC.

Is this possible? Any other suggestions?

I think it should be possible, even if you only set a daily alarm on the RTC, so that it fires an interrupt at exactly the same time every day.
Then the tiny would just need to set the same time as the RTC alarm time whenever it receives the interrupt. No polling needed.
For reasonable accuracy during the day, the tiny couldn't really run on it's internal oscillator though, or the timing could go a fair way out between interrupts, over a 24 hour period.

That would be the minimalist approach - very little ATtiny code overhead, but not particularly accurate.
You could set more frequent alarms - more accuracy at the cost of higher code requirements.

Quite doable though, I reckon. And with a good crystal and the right load capacitances, even a daily time update could produce reasonably accurate results.

Until I saw your post, I wasn't even aware that the "Time" library could operate without an RTC, but a quick test showed that it works fine. Never too old to learn. :slight_smile:

Edit: Of course, you'd need to use a UNO or something to initially set the RTC time and alarm(s), then connect it to the ATtiny.

Never too old to learn. :slight_smile:

We have to write the new things we learn down though, as:
We are too old to remember :wink:

.

LarryD:
Never too old to learn. :slight_smile:

We have to write the new things we learn down though, as:
We are too old to remember :wink:

Ha ha. You're quite right, Larry.
I've already saved the sketch that I just wrote for the UNO, titled "TimeWithoutRTC.ino", so I can see it easily to jog my memory. :slight_smile:

Need to try that, in principle it shouldn't be much of a problem if the time drifted 10 minutes of less over a day. The crystal would somehow defeat the whole idea of saving pins.

Other than the obvious reset at 0h00min how would one input the time to the time library manually inside the code?

amvcs08:
Need to try that, in principle it shouldn't be much of a problem if the time drifted 10 minutes of less over a day. The crystal would somehow defeat the whole idea of saving pins.

Other than the obvious reset at 0h00min how would one input the time to the time library manually inside the code?

That's easy. If you set the RTC alarm for once a day, at a certain time, you know what time you set it for, so your Arduino code sets the 'Time' library time to that particular time when it receives the interrupt.

ie Alarm at 9:30:00am daily, Arduino sets time to 9:30:00am on interrupt. To keep timing as close as possible, the internal oscillator would need to be calibrated. From the factory, they're only calibrated to within 10%, but with user calibration, 1% is possible.

You didn't say which ATtiny you're using. If it's a tiny85, stepping up to an ATtiny84 would give you more pins without using too much more board space, and allow enough pins for a crystal or ceramic resonator.

LarryD:
Never too old to learn. :slight_smile:

We have to write the new things we learn down though, as:
We are too old to remember :wink:

.

I gotta remember to steal that one... Terry02281940

I can't remember why I started the http://ArduinoInfo.Info WIKI -- probably so I could remember stuff.

I can’t remember why I started the http://ArduinoInfo.Info WIKI – probably so I could remember stuff.

But, if I remember your site, you are doing a great job.

.