sachleenblogprojectsabout me

Alarm Clock Hardware

This is the hardware setup of the alarm clock.

Alarm Clock Breadboard

Main Components

The 4 digit 7-Segment display displays the current time. The LCD displays the date and allows the user to configure the clock settings and set alarms using the three buttons. The buttons provide a simple and intuitive way to interface with the clock. From left to right, the buttons are previous, select, and next.

Since there is no battery backup, we included an EEPROM to save the user-set alarms and configuration. The current date and time will need to be set again if the clock loses power.

I talked about the motion sensor in my previous post: Body Movement During Sleep.

We bought a 5 x 2.5 x 2" Project Enclosure from RadioShack to put everything together. After a lot of rough measurements and guesstimation about how everything will fit together, we cut out the holes for all of the components:

Alarm Clock Case

To power the clock, we initially used a 12v DC power adapter I had laying around. (I couldn't find a working 9v adapter and a 5v adapter was not enough to power everything.) Because the plug was too long to fit in comfortably with all of the components of the clock, we cut it off and soldered the wires from the adapter directly onto the connector on the board. We eventually scrapped this idea and went with a USB cable (still had to solder the wires directly onto the board) for two reasons: First, with how tight everything was inside the box, we didn't want to have to open it up any more than we needed to. Having a USB connection would allow me to program the clock without having to open it up. Second, we noticed the board was getting very warm after a couple minutes when being powered from the 12v adapter. According to the Arduino Uno page, the recommended input voltage is between 7 and 12v, the maximum being 20v so it shouldn't have been a problem but we err on the side of caution.

Alarm Clock Guts

After some more testing, the clock stopped working. Turns out, it had to be reset after being given power for the sketch to load. After some unsuccessful Googling we took everything apart and tested each of the components individually. The fault lies in the LCD. For reasons I have yet to understand, when the LCD is connected, the Arduino will not load the sketch on power-on. To fix this, we added a resistor to the reset pin and 5v. Still don't understand why this is necessary, or why it works, but it just does. To make sure this wouldn't interfere with anything else, we added a switch on the back of the clock. This way, we can "disable" the resistor hack if need be.

Here's the finished product:

Alarm Clock

So that's the rundown of the hardware of our "intelligent" alarm clock! The software still needs some work, but it's coming along nicely. Thanks for reading!

Body Movement During Sleep

This is the first real step forward in creating an intelligent alarm clock, the final project for my Computer Interfacing course.

The idea is to have the clock monitor body movements and go off when you're in "light sleep," rather than at a fixed time. The obvious advantage of this is you will wake up feeling good every morning. This project was inspired by the iDreamSaver Kickstarter project.

Analysis of the relationship between body movement intervals and depth of sleep showed that the interval between body movements was longer during deep sleep and shorter during light sleep.1

I got a PIR Motion Sensor yesterday and hooked it up to my Arduino and wrote a sketch to print the timestamp to the serial terminal whenever motion was detected. (View Source) I then wrote a Powershell script to input from the serial port and write the data to a text file. (View Source)

This morning I put the data into Excel and plotted it. This is what I saw:

Graph 1

This graph shows an "x" at every point throughout the night where the sensor detected motion. Not very useful but we do see some areas where there are groups of "x"s and some areas where there are very few.

I then ran the data through a PHP script to group the data into number of motions detected (limited to 1 per second) per minute. (View Source) Graphing this shows something more interesting:

Graph 2

Here we see after about 30 minutes body motion was minimal. This suggests I was in a deeper stage of sleep during that time. This is in line with what Hagiwara and Jo report in their paper. (I was only able to find the abstract in English so I was not able to get the details of their findings.)

The spike at 250 minutes (around 4:30AM) is when I woke up only to realize I could sleep for couple of hours longer. I recall the time being 4:38 when I looked at my clock and I was already facing it. This means I turned around to face the clock but actually "woke up" 8 minutes later to see the time, and then turned back around (indicated by the shorter spike at 265).

The data suggests I was not able to sleep very well (compared to the time period between 30 and 240 minutes) after waking up once and finally got up at 400 minutes (7:00AM), when I shut everything down.

This is really cool! I'm a little surprised at how well it worked. The most interesting part of the graph is the spike at 250 minutes when I woke up to look at the clock. I hadn't made the connection between the two until I realized 250 minutes was around 4 hours and I remembered waking up at around 4:30!

I'll be posting more often with updates on this project. Stay tuned!

  1. Hagiwara, Hiroshi. "Evaluation of Body Movement during Sleep Using an Infrared Motion Sensor." Japanese Society for Medical and Biological Engineering. 47. (2009): 7-14. Web. 12 Apr. 2012. <http://www.jstage.jst.go.jp/article/jsmbe/47/1/7/_pdf>.

A New New Tab Page

NTP

Working on a new new tab page extension for Chrome! Not sure if I want to release it to the Web Store yet...

Happy Leap Year!