Tuesday, November 29, 2005

Christmas X10

by Jason

At first glance, you might be thinking "Christmas times 10?" Not quite, but no matter how you read it, it's cool. Allow me to explain...

I decided over the weekend that the little timers we had were very insufficient to control our Christmas lights. I mean, the time the sun sets will vary by 5-10 minutes from the time the lights go up until Christmas day! Sure, there are the little light sensor units, but on a cloudy day, who knows what you'll get?

So, I decided to automate the control of our Christmas lights using something a little more sophisticated: my computer. This should not have come as a surprise to you.

Before I could use my computer to perform all manners of light manipulation, I needed a way to interface it to the lights themselves. Oh, and it had to be cheap. This is where X-10 comes in. X-10 (for those that don't know) is a powerline signal carrier that allows you to control electronic devices using a controller such as a switch, remote, PC, etc. The cool thing about X-10 is that powerline signal carrier bit: this means that in order to control something, all you have to do is plug it in using one of the X-10 modules. No additional wiring is needed.

Okay, I've got my FireCracker, Lamp Module, and Transceiver all in place (they all come as a nice Kit). I've got the lamp module hooked up to the tree, set up the proper home & channel ID, and presto! The tree lights up the first time! There is a little piece of free software that the X-10 folks give you to control the FireCracker. It looks just like one of the palm remotes. This is okay for simple control from the PC, but something is still missing: the automation.

There is a piece of software that looks pretty reasonable: FireworX-10. Trouble is two fold: it requires that the software is running for the timers to work properly, and I didn't write it. So, without any hesitation, I proceeded to learn the FireCracker protocol. Now, although this is connected to a serial port, the protocol is not RS-232. They left those lines alone for other devices. Instead, it is all about diddling the DTR and RTS lines. There is a good guide here. After a bit of fussing and more Googling, I was able to hack up a Perl script that produced the correct control of the lines with the correct protocol.

So now, I have my script that allows me to say "turn on device 2" or whatever, but we still haven't achieved the goal of automating the Christmas lights. I return to my Perl script and give it the ability to run a little scripting language that I made. This scripting language is basically a sequence of "turn on this" and "turn off that" commands, but it has another special little feature: it knows how to interact with the Windows Task Manager. Now I have my little script that is able to read my little scripting language and knows how to install little tasks to run at certain times. I've even gone so far as to create little keywords for the scheduling like "sunrise" and "sunset"; can you guess what those are for? Of course, this requires knowing your latitude and longitude. If you don't have a GPS device handy, just use Google Earth. Think we're done? You know better...

Automation is neat, but what ties this all together is being able to control it from the web. Of course. So I created a PHP page that interacts with my little script to control the lights at home. I still need to make this page capable of controlling the schedule, but that shouldn't be too hard. I'm not going to give you the address to look at the page. I don't want my lights turning on at 3:00a.

Finally, after all this, I have my complete setup. Here's the skinny: every day at midnight, my little program kicks off and reads a script that sets the schedule for the day. Currently, this script schedules the Christmas lights to come on at sunset. The script that runs at sunset to turn on the lights also schedules a task to turn the lights off at midnight. Nifty eh?

Total cost of the endeavor: $50 (the FireCracker kit + 2 additional Lamp Modules). eBay is a great place to find X-10 parts cheap, just watch the shipping costs.

Categories:

5 Comments:

At 29 November, 2005 16:31, Blogger Ken said...

I only have myself to blame (:

Love Ya Dad

 
At 29 November, 2005 17:15, Blogger Erica said...

Summary: It is very cool.

 
At 30 November, 2005 08:40, Blogger mom heddings said...

This is scary.

Jason, I bought a timer at WalMart for $15 that turns on the lights at sunset and turns them off 6 hours later. For some reason, this seems a whole lot simpler to me...... your low tech mother. Yes Ken this is all your fault!!! Erica, there is still hope for you honey---we need to talk.

 
At 30 November, 2005 14:06, Blogger Dawn said...

Jason,

You have way too much time on your hands. I think you need a few children, say three. It keeps Scott busy enough to have stopped the majority of these tendencies. : )

 
At 01 December, 2005 15:12, Blogger Dad L said...

What scares me, is I enjoyed reading the whole thing! I wish I was 30 years younger and could start school all over again to learn more about this stuff. Erica doesn't remember some of my mechanical inventions like the device to keep the humidifier full of water or the boat lift in the rafters of the garage that dropped my jon boat into the back of the pickup as I backed in. The world would probably not be a safe place if I had tinkered with techy stuff. I love it!

Dad L

 

Post a Comment

<< Home