Activate the geek mode to get detailled explanations

Christmas trees are cool, right? What about a smart Christmas tree? Wait, is this future? No, it already exists, it’s here!

In the past years I just used a power outlet timer to control when my tree should be illuminated and when it should not. Well, for this Christmas I’m gonna control this from my phone, or even by sending a tweet!

In this post I will detailed the process I followed in this project, from the hardware to the software.

First I found these cheap remote controlled power outlets for about $12. Okay cool, I could already control my Christmas tree lights without getting my ass of this chair. Let’s go further!

What I really wanted to do was controlling the remote from an Arduino board (an open-source electronic tool to control hardware with software basically). In order to make that happen, I connected the inputs of the remote (ON/OFF buttons of each power outlets) to a relay because the remote is powered by a 12V A23 battery. And this relay is commanded with the 5v of the arduino outputs.

The next step was to connect the arduino to the Internet. To achieve that, I used an ethernet module that cost me $2. At this point the hardware side was almost complete, so let's talk about some of the code I wrote.


On the board, it was quite easy, even if I have not much experience with this programming language. I began by writing some functions to trigger the remote buttons and building a string with some data I could get to monitor the device like the state of the power outlets.

After that I designed a webserver with the Ethernet module library and served the data string as a Json file. I also listened for requests to trigger the power outlets switch so if I would go to http://ethercardip/po1 it would command the first power outlet and so on. I also added several modes to control the system from other sources like electronic sensors (light sensor, reed switch…).

Using this API, I quickly build a web interface with buttons to control modes and also switch on and off the first power outlet (I actually ended up using only one of them, even if two are connected to the arduino).

I developed the software to be able to trigger the power outlets from a webpage, and also from electronic sensors.

web interface

When I started this project, I really had no final goal except having fun and impress my friends with this thing. Then I thought of making a video to show creative ways to interact with a Christmas tree. And by the time you are reading this, the video is already up!

The video at the top of this post is explaining the technical and developing process and how all that came up.

And remember, all I did was controlling power outlets, so this could be used for any device plugged in your wall. I hope that this inspires you, and if you have questions, suggestions about this project or anything else, leave a comment below.

See you soon!


See the code on Github: Open source API to control your plugs from anywhere

schematics arduino smart plugs