Schrödinger's clock

I'm very new to arduino, but i've learned as much as i can. im trying to create a self reliant program that will turn on lights at the same time each day (aquarium) it also has to monitor temp and turn heater on if required.

i have downloaded,tested and inspected numerous timer routines, whether they refer ,or not, to (millis) is completely irrelevant, whether they get signals from this place or that place is neither here nor there, they all have the fatal flow in that they are not (gmt) timers but just loop counters. you may as well declare seconds =seconds +1 delay (1000)

as soon as you tell arduino to do something at (x) time then you stop the timer, if this loop/subroutine ran at a constant rate then you could add time to timer routine to get where you left off. but not all routines/loops that are called are for a definitive time. the timer is in essence like schrodingers cat , that being that it will absolutely tell the correct time until you say, "What time is it Arduino?". this question and reply from arduino takes time and slows the clock.

am i correct or am i completely missing something?

millis() does not have this drawback but is relative to when the Arduino first received power and not GMT.

A Real Time Clock shield can give your Arduino GMT but is an additional cost.

References to millis() are not irrelevant if you look at the correct examples. See the Blink Without Delay example for one such example.

What you are asking to do is not impossible and has been done before.

You can purchase RTC's on eBay for under a dollar. Googling "Arduino RTC" turns up about 390,000 hits, so one of those will likely help.

craig68: the timer is in essence like schrodingers cat , that being that it will absolutely tell the correct time until you say, "What time is it Arduino?". this question and reply from arduino takes time and slows the clock.

am i correct or am i completely missing something?

yes, you missed the time it takes for the photons from the Arduino's display to reach your retina, be processed into a visual message and transmitted to the optical processing part of your brain.

Plus of course, as I'm sure you know, the progression of time would depend on the gravitational effects relative to your distance to the center of the earth (i.e if you are on a mountain top or at sea level).

craig68: turn on lights at the same time each day

am i completely missing something?

Yes, the difference between a clock, which you need, and a timer, which you don't.

Invest $1-34 in a DS1307 real time clock, and you will quickly realise what an utterly futile exercise you have been engaged in. You can then forget about the cat.

Nick_Pyner: You can then forget about the cat.

Just don't forget to put the cat out!

BulldogLowell: Just don't forget to put the cat out!

If it's alive, and who can know that.

To the OP: if you don't want to include an rtc (although, why wouldn't you?) you can use the Time library to create a software clock, to do the same thing. It's not as accurate though.

You can do without a RTC if you want. You just need two millis()-based delays. Let's say you want to command a relay and want it to stay on for 1 hour each day. Your code should do this:

1) when the arduino is powered on/reset, set a pin high: this is t0;

2) at t0 + 1 hour, set the pin low;

3) at t0 + 24 hours, set the pin high again and so on.

The arduino doesn't need to know what (wall clock) time of day it is. You just need to be there and power up the arduino the first time at the time of day you want. If this is 3 am or another inconvenient time, just set a one-shot delay in your setup code, so if you power up at 8 pm, it will wait 7 hours and then go ahead.

You have to use millis() because you want the arduino to do other things in the meantime (monitoring, temperature control). Otherwise, even blocking delays would do.

I don't think you need to be too accurate for this task. Even an error of a few minutes will hardly affect anything.

BulldogLowell: yes, you missed the time it takes for the photons from the Arduino's display to reach your retina, be processed into a visual message and transmitted to the optical processing part of your brain.

Plus of course, as I'm sure you know, the progression of time would depend on the gravitational effects relative to your distance to the center of the earth (i.e if you are on a mountain top or at sea level).

Seems to be no "like" option on this forum, but your post made me laugh..

ROFL

And this is not so much a Shrodingers clock as a catch 22 clock.

hexreader: Seems to be no "like" option on this forum, but your post made me laugh..

ROFL

The 'add' karma is the same as 'like'.