A high-tech night light

I mentioned this in another thread a week or so ago. Strictly an educational sort of project, but it has several interesting points, so I wrote a blog entry about it. The code and schematic are available on github.

Features include:

  • Clocking Timer2 from a 32.768kHz crystal, and implementing an RTC in the ISR
  • Use of Power Save mode to conserve the battery
  • Automatic daylight saving time adjustment
  • Calculation of sunrise and sunset given latitude and longitude

That is actually very cool Jack, thanks for the contrubution.

While certainly an overkill for a simple night light, much of that code could be reused in much more complex applications like steering a solar panel so that it tracks the sun during the day and shuts down at night and wakes to start tracking from the east at next sunrise time.

Lefty

Thanks, Lefty. Sometimes I see things in the datasheet or whatever and they sound interesting, so I'll try them out whether I have an immediate application for them or not. Expands my repertoire XD but if other folks can use any of it to advantage, then that's great too!

Did some sunrise sunset analysis some time ago, see - http://arduino.cc/forum/index.php/topic,66426.0.html -

For a fixed location a workable formula becomes quite simple (no DST support :(.

robtillaart: Did some sunrise sunset analysis some time ago, see - http://arduino.cc/forum/index.php/topic,66426.0.html -

For a fixed location a workable formula becomes quite simple (no DST support :(.

Interesting, you managed to pare it down quite a bit. An early post in that thread has a link to the same algorithm I'm using. I tweaked it just slightly, for rounding, and got it to the point where it was always within one minute of the USNO table. The USNO table varies slightly year to year, perhaps axial precession is calculated in, whereas the algorithm I'm using returns the same values every year. I'm not planning to be around once its error becomes significant ;) so will leave that improvement to future generations.