Most economic External clock to Arduino?

I need to do GPS and temperature readings at some 5 minutes, preferably in relation to real time (but not mandatory).

I came across various RTC modules, but looks to much complication for this punctual task.

Question:

a) Is it any chance to use a sort of external oscillator (a quartz?) to keep track of time, a simple circuit? Precision is not a problem.

b) Is there any practical experience with using Arduino software to keep track of time (I read about mili(), but no idea how practical may be).

Any particular reason you do not want to use the GPS as an external clock?

GPS will not be always in use (for instance: under cover, no reason to record, not recording etc.) while temperature shall be independently measured.

Besides this, once learnt, I can synchronize sensors, actuators etc. while no GPS in use.

====

I al going to store everything in EEPROMS (and or FRAMS), so I shall be careful with the numbers of writings. O figure out how to store integers (EEPROMS wired and programmed), I know how to display on LCD (wired and programmed), I already got how to measure the temperature (wired and programmed).

It will be a Robo-Cat. :-))

falexandru:
b) Is there any practical experience with using Arduino software to keep track of time (I read about mili(), but no idea how practical may be).

Yes, it is really easy to do something every 5 minutes with millis(). Just look at the Blink without Delay sketch in the IDE. Change the time from 1000ms to 300000ms.

falexandru:
a) Is it any chance to use a sort of external oscillator (a quartz?) to keep track of time, a simple circuit? Precision is not a problem.

No need, millis() is all you need. While not perfectly accurate, it should be good enough for you. Sync time on the GPS when you have it available, the rest of the time rely on millis().
For ease of getting the current time, check out the Time libary.

I checked the millis() in reference section. Looks easy indeed, at least for simple tasks or successive events well-separated in time.

I still worry about clarity of code as handling long int leads to huge values. The example on IDE is only about one LED, which sounds reasonable. Is this method sound enough to perform many ifs or when providing for parallel events?

Does the internal Arduino Clock respond well to handling various peripherals via I2C?

My concerns come from paralell use of 4 EEPROMs on I2C. I had to delay each write operation to get the correct writing. I could use the checks instead of blind delays. But anyway, I run the test sketch several times in row, changing the delays and sometimes 3 milis were enough, sometimes I had to increase to 5 milis. Does not matter to much (especially when I will shift to checks) but this behavior worries me in respect of reproductive time keeping (either internal or external clock).

The datasheet for your EEPROM chip will specify how long writes take.

@Wvmarle

Good idea to sinchronize when I get the GPS signal!

I only have to find a way to code this "synchronize when GPS is available" - perhaps an endless external loop to check every -say - 10 s if a NMEA sentence is received? For the moment, I cant figure out how to code this operation.

Indeed, as @aarg also stated, milis should be good enough for non-critical time keeping. The only point in having an external clock may be in avoiding a to complex code in using the internal clock (if the case may be).

Since I do not have any experience, I just want to follow the easiest path (i.e. either internal or external clock).

falexandru:
My concerns come from paralell use of 4 EEPROMs on I2C. I had to delay each write operation to get the correct writing. I could use the checks instead of blind delays. But anyway, I run the test sketch several times in row, changing the delays and sometimes 3 milis were enough, sometimes I had to increase to 5 milis. Does not matter to much (especially when I will shift to checks) but this behavior worries me in respect of reproductive time keeping (either internal or external clock).

It seems to me, that has nothing to do with millis() timing, rather is an issue of EEPROM timing.

Let’s be clear here. You just want to do something every 5 minutes, or you need the current time as YYMMDDHHMMSS?

@Jiggy-Ninja

No datasheet available for my EEPROMs (there are of "Generic" type ;-)). They cost some 50 Cents each, comparing to 2 -3 USD each for the brand ones.

@ aarg

In fact, it is planned to work like this:

I wake up my Robocat.

Then the time starts.

I have 2 basic options:
a) to set the wake-up time in relative values - say 0 (and then count) -either using internal or external clock
or
b) to refer to real time - either GPS based or RTC module.

Which ever is simplier both in terms of hardware and programming.

One second or more drift per day is not a problem.

I only worry about the influence of time keeping problems to the setup. The memory is on EEPROMs, most (if not all) sensors and memory shall be on I2C (this part is partially done). The cat movement part is not yet designed.

====

I have no idea how practical is an external RTC. I read about them, but most of the time people make clocks out of these modules and are concerned about precision, drift etc.

falexandru:
@Wvmarle

Good idea to sinchronize when I get the GPS signal!

I only have to find a way to code this “synchronize when GPS is available” - perhaps an endless external loop to check every -say - 10 s if a NMEA sentence is received? For the moment, I cant figure out how to code this operation.

How about whenever you get a GPS location from your receiver? Can’t you get a time stamp with that?
(sorry, no direct experience with this).

You basically suggest to check time continuously with the GPS and correct only when required, am I got it?

You do know that GPS reception is marginal to non-existent indoors, right?

Yes, I know no GPS signal is available indoor. Not even outdoor (city canyons, forests etc).

So my robo-cat must be a partially outdoor cat :-).

falexandru:
You basically suggest to check time continuously with the GPS and correct only when required, am I got it?

That's the idea - but you should also make sure you have some form of verification that the time you get from your GPS module is valid. If no GPS reception, like indoors or in tunnels, time may be off as well - check your module documentation on this.

falexandru:
Yes, I know no GPS signal is available indoor. Not even outdoor (city canyons, forests etc).

So my robo-cat must be a partially outdoor cat :-).

I think unless you use an RTC, it will have to be a feral cat. :slight_smile:

aarg:
I think unless you use an RTC, it will have to be a feral cat. :slight_smile:

Well, in fact nothing stops me to go both ways: relay on GPS when signal available and on internal clock when not. Adding a specific RTC module may worth adding, but pushing it into I2C may be difficult.

The Robocat may also grow up :-))

You’re not likely to be off more than a few seconds a day, if you rely on the internal timekeeping. So whether it’s worth adding an RTC depends on the accuracy you need, and how long you may be without GPS signal.