Build your own wake-up light alarm using X10, Raspberry Pi & Linux

I once owned a Philips Wake-up light that waked me in the morning. The Wake-up light simulates the rising of the sun and wakes you up in the morning by brightening light gradually for 30 minutes until the room is lighted completely. Newer versions of the lamp also change color to simulate the sun even better, but personally I think this is more of a marketing trick to sell more wake-up lights.

 

X10 Wake-up light

X10 Wake-up light

If you have a X10 module that can be dimmed, you can achieve more-or-less the same by using a very simple script that will wake you up in the morning without buying an over-expensive alarm-clock/light.
In this tutorial I’m using a Raspberry Pi Linux system connected to a CM11 module to control the lights in my house. If you need a tutorial on how to setup this system, please take a look at my tutorial on setting up the Raspberry Pi.

I have a light near my bed that is controlled by a LW12 micromodule that is installed behind the light switch in the wall. The module supports On/Off and Bright/Dim methods, which is just what I need for this purpose.
Since the Raspberry Pi is running on Linux I’m going to use crontab (scheduler) and a simple script to start the wakeup procedure in the morning.

First the script (replace the X10_ADDRESS with your correct X10 light module address):

#!/bin/bash
HEYU=/usr/local/bin/heyu
X10_ADDRESS=B2

for i in {1..11}
do
   $HEYU bright $X10_ADDRESS 2
   sleep 90s
done

exit 0

This (very) simple script uses Heyu to bright the lights step-by-step and sleeps 90 seconds between each bright command. This works well when the lamp(module) is switched off, since the first step turns the module on and then brightens the light gradually from there.

I saved the file in /usr/local/bin/wakeup.sh
Make the file executable by:

sudo chmod +x /usr/local/bin/wakeup.sh

You should now be able to test the script by:

$ heyu off B2
$ wakeup.sh

Your light should be turned on and be brightened every 90s.

Next step is to call this script from crontab to set our alarm timer.
Crontab (the linux default scheduler) allows you to specify when this script is called. Crontab is very flexible and configurable, which comes in handy, because I want my script to be called every weekday at 7.00u in the morning. Simple enough:

$ crontab -e

Now add line to the crontab configuration like this:

0 7 * * 1-5 /usr/local/bin/wakeup.sh

This tells cron to run our script every weekday (1-5) at 7 in the morning.

Admittedly, it does not change color or play a natural sound, but it woke me this morning pretty nicely. Even better, it does not have a snooze button, no excuses to stay in bed!