Wednesday, May 07, 2014

Daylight Alarm Clock - Real-Time Clock

My wife and I are not sure yet whether this whole daylight alarm clock thing is a good idea but I'm pushing ahead for now.  The light failed to wake us the one time we've tried it and the the little direct light that came our way (the lamp was pointed at the ceiling) was too intense for early in the morning.
The first change I've made is moving the light from the dresser across the room to my night stand and putting it under  "frosted glass" (heavy scratched now translucent plastic bowl). We'll see if this works any better.

The big electronics improvement for this test is the use of a real-time clock module, driven by a DS1307. If you don't do much with embedded systems like this, it may not occur to you that the Arduino doesn't come with a built-in clock; it literally has no idea what time it is. To solve that problem common problem, there are many readily and cheaply available modules that can be purchased and wired into the Arduino.  These modules can be queried to determine the time and data and have a battery back-up so that even when they are not being powered by the Arduino, they still keep track of time.  Program the module once with the current time and you never had to worry again.

(Never is an approximation.  At some point the battery will run out and the modules have a reputation of being not atomic-clock accurate. Time can drift several seconds per day.)

Before the inclusion of the real-time clock, I had to program the Arduino with the specific number of seconds from when I plugged it in at night to when I wanted to light to begin fading up the next morning.  Now, with the real-time-clock, I let it take care of worrying about keeping track of time and I just have to program in what time I want to the fade to start.  This is progress and a lot more accurate than my previous technique.

We'll give it a few mornings try and see if we like it any better.

No comments:

Post a Comment