Working on my first project. I have a relay board to control lights and I have a photosensor outside. So I can figure out how to turn the lights on when it gets dark but the only way I know of is to turn the lights off after a time limit has passed. That works say for the summer but when the winter comes the lights need to stay on longer. Is there any way to turn them off at a set time like 11 PM
Thanks Rick
Sure, add an RTC module and sample the time. Or an RTC module with alarm features.
Thanks CrossRoads
Looking on Ebay there are allot of different types with different descriptions. Is there anything that I should be looking for just to add time to my projects
After you post I was doing some reading and I came across this
(cut and Paste)
http://playground.arduino.cc/Code/time
Arduino Time library
The Time library adds timekeeping functionality to Arduino with or without external timekeeping hardware. It allows a sketch to get the time and date as: second, minute, hour, day, month and year.
Does this mean that I can use time in a sketch without any additional hardware
Sorry Im kinda answering my own questions here
I think the only difference in using external hardware is that if i reset my arduino then I will have to program time again with external hardware I dont
Reset or power off in any fashion will mean it needs to be reprogrammed.
External will also be more accurate
An RTC module is the obvious answer - they're cheap, and there are plenty of examples showing how to use them. I think there are also some libraries which make it easy to schedule things to happen at specific times.
You could implement a solution which is far less accurate and far more complicated without using an RTC by measuring the interval between dawn and dusk and assuming that half way through this interval represents noon. You would probably want to average that answer out over quite a few days to get a stable answer unaffected by weather etc.
Thanks guys an RTC Module it is
Hi,
RTC Info, code on the ArduinoInfo.Info WIKI HERE:
how do you adjust for daylight savings
Do i have to adjust the clock manually
Do i have to adjust the clock manually
That's what I do.
Trickyrick:
how do you adjust for daylight savings
Why do you need to adjust for daylight saving? You stated you wanted to turn the lights on at dusk, do you not stay up later when you have daylight saving?
![]()
how about setting a timer for the time the photosensor detects light
run until it fails from the loss of light.
add 11 hours to the center point of that timing.
average days and delete any days that are cloudy by ignoring values that are more than 20% off of the expected norm.
granted that it will not be dead accurate, but you could hit a target window of time to turn off without adding more pieces.
Dave