[Paulo’s] garden lights are probably a bit more accurately automated than anyone else’s on the block, because they use latitude and longitude clock to decide when to flip the switch. [Ed Note from the far future: this page no longer exists, but you can still read it on the Wayback Machine. The TimeLord library has also been superceded, so you’ll have some porting to do.]
Most commercial options (and hobbiest creations) rely on mechanical on/off timers that click on an off every day at the same time, or they use a photosensitive element to decide it’s dark enough. Neither is very accurate. One misplaced leaf obscuring your light-dependent resistor can turn things on unnecessarily, and considering the actual time of sunset fluctuates over the year, mechanical switches require constant adjustment.
[Paulo’s] solution addresses all of these problems by instead relying on an algorithm to calculate both sunrise and sunset times, explained here, combined with swiftek’s Timelord library for the Arduino. The build features 4 7-segment displays that cycle through indicating the current time, time of sunset and of sunrise. Inside is a RTC (real time clock) with battery backup for timekeeping along with an Omron 5V relay to drive the garden lamps themselves. This particular relay comes with a switch that can force the lights on, just in case.
Check out [Paulo’s] project blog for the full write-up, links to code and more details, then take a look at some other home automation projects, like the SMS-based heater controller or occupancy-controlled room lighting.
Informative thank you!
So, a smart mechanical on/off timer?
Most commercial automation systems have astronomical clocks built in.
Also, nice application to use the arduino to accomplish the goal effectively .
Great. As I got home from work last night and my automated garage door opener opened the door for me I thought “that needs to switch the lights on”. It’s normally light when I get home, but not this time of the year. It’s networked so could grab the date and time. Much nicer than a light sensor.
Disadvantage is that it requires to keep the time accurate. I would add a photosensitive device, and maybe use some software to filter out false events.
Instead of an RTC, you can use a GPS to get time without need for setting/recalibration with the added beneffit of latitude info for timing calculation!
I’ve been doing the same with a Raspberry Pi, sunwait, cron and X10 for some time now: http://scruss.com/blog/2013/02/06/hey-its-the-sun-heyu-and-sunwait-and-cron-on-the-raspberry-pi/
You can buy a “Astro” relay ready made. You just set time,date, location once.. so simple :-)
http://www.schneider-electric.com/products/ww/en/1600-din-rail-modular-devices/1650-acti-9-lighting-time-energy-management/843-ic/?XTMC=astro&XTCR=2
A disadvantage of this over a photosensitive device is it doesn’t take cloud cover into consideration.
so add a pho-d and use logic in your script: if within x time of sunset and if output less than x.x VDC, then on. if within x time of sunset and if output greater than x.x VDC, then no action. if sunset, then on. not difficult.
To be worthy of the name “astronomic clock” it should at least account for eclipses.
Lat/Long isn’t enough if you have a mountain that blocks the sun part of the day.
e.g. a mountain to the west will cause earlier sunsets.
So feel free to adapt accordingly, if necessary. Not necessary for many folks though…
Well, it depends on what you mean by “sunset”. I live in a valley with mountains to the west, and I’ve been using an astronomical timer to control outdoor landscape lights at my home. (I wrote C code, running on a beagleboard, controlling lights via X10 and getting time over the Internet via NTP).
It becomes impossible to see the sun after it goes behind the mountain. But there is still plenty of light from the sky. The calculated sunset time corresponds pretty well to the time that additional artificial light is required in order to see well. It doesn’t correspond to the time that my home falls into the shadow of the mountains, though.
If “light sensors” were the big new thing, and astronomically-based clocks the norm, someone would have created a light sensor based switch, and this story would have been raving about its accuracy, how it doesn’t just switch on the light based on dumb calculated timings, but about the actual light conditions of that day, etc. etc.
It seems like a fun exercise though(!!); but not necessarily more practical than a simple, effective light sensor…?
I have a home automation system with a central control that I programmed myself. I turn on outside lamps at dusk. I first did so by using a light sensor, but it required battery replacements, and communicated with the rest of my system by interference-prone radio, so it wasn’t so reliable. I eventually programmed in astronomical sunset calculation. I kept the light sensor around, though, and kept a log of sunrise and sunset times, both calculated and observed by the light sensor, for a few years.
I was surprised. On days when the lights sensor works, regardless of weather conditions, its time is always within about 4 minutes of calculated sunset/sunrise time, usually much closer.
For the purpose of turning on lights at dusk, either method should be good enough. The choice comes down to whether you prefer the burden of maintaining an accurate system clock, or the burden of purchasing and maintaining the light sensing hardware.
That’s interesting information, Richard! I suppose it may also depend on what kind of climate you live in – for instance, where I live we often get overcast skies or days where it gets quite dark because of thunder clouds (especially when these occur near sunset), which are obviously not related to the astronomical time. But I like hearing that it usually corresponds very closely in your experience, I wouldn’t have thought it would be that close!
That’s interesting. Part of my motivation for building this was that I found the photo-cell based timer I have to be quite inaccurate. Sometimes it would turn the lights ON on a cloudy day. These were Christmas lights and I only wanted them on at Night. I suppose it also depends on where you have the timer located. Mine was in a shaded area under the front entrance, surrounded by plants etc, so it was already on the dark side to start with….
Need it for my reef tank….
Maybe a second Trinket is in order?
To make it a bit more automated you could add one of these https://www.sparkfun.com/products/10533
So you can update the time from your PC. Just interface this https://www.sparkfun.com/products/10535 to a serial or USB port and write a bit of software that updates the clock once every day or so. Or you could use one of these and have two way communications for setting the times or checking the status. https://www.sparkfun.com/products/9582
good effort on getting the astrometrics right in the programming.
However, going to the home depot and getting one of these would have worked too.
http://www.homedepot.com/p/GE-3-Way-Sunsmart-In-Wall-Digital-Timer-15312/202788253#.Uoa7-uL3OKI
For crying out loud, doesn’t anyone know how to spell “hobbyist?” Or how to use a spell-checker?
The author mentioned in the beginning that you can buy something like this, (there was even a link to a product there). Those comments stating you can buy this and that product totally miss the point of an electronics hobby (and of this site for that matter). If all you have as motivation for building something electronic these days is saving money, then you might as well not do anything. 99% of things you can think of can be bought and are cheaper when bought. You do something like this because you love to learn and because of the rewarding feeling of building something. Nice Project.
I’ve got a mechanical timer, 50 or 60 years old that adjusts itself for the seasonal change in sunrise/sunset, clearly for controlling outdoor lighting. In addition to the 24hr disc with the two hands controlling the switching moments, there’s a mechanism with a second disc, geared down to make one revolution per year. Through an excenter it drives a mechanism that moves the switch actuators, delaying and advancing the switching moments; the total variation even appears to be adjustable. It’s also spring-driven, with a motor winding the spring, so it can handle power outages. Of course not millisecond-accurate, but good enough for street lighting and such, back then.
Hi Stoneshop.
I’m the author of the article. Thanks for that piece of information. Fascinating that this can be done with a mechanical device… Would love to see a photo of one of those devices.
Thanks,
Paulo
Paulo .. Tried your link seems to be down .. Can I get your schematic and sketch code from somewhere else?
Garmin GPS receivers use the same thing to determine whether or not to go into night mode.
Site seems to be down .. Anyone got the schematic and sketch code?
There are commercially available “Astronomical” switches commonly available from Honeywell (Aube) and I think Intermatic. The big problem however is trying to set your switching events to something other than sunrise or sunset. The Honeywell has the ability to offset an event to sunrise or sunset ± about 70 minutes. If you want to create a timer that switches on at, say four hours before sunrise (think lightswitch timer for poultry) these switches won’t work. Paulo Renato’s timer is the perfect solution.
You have DEAD Links!!!!!
But we also have the Wayback Machine, and we’re not afraid to use it!
Fixed. Thanks for bringing it up.
Next time if you want to reach us directly, instead of hoping that we see comments in an eight-year-old post, just shoot an e-mail to editor@hackaday.com.