Arduino Astronomic Clock Automates Lights

ardAst

[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. 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.

30 thoughts on “Arduino Astronomic Clock Automates Lights

  1. 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.

  2. 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.

  3. 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!

    1. 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.

  4. 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.

    1. 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.

  5. 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…?

    1. 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.

      1. 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!

        1. 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….

  6. 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.

  7. 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.

    1. 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

  8. 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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s