Last year one of the interesting posts in TwiTip that really caught my attention was the post about how to turn a bedroom light on and off with Twitter.
In the comment, I hinted about how that hack works — after peeking at the source code. For most people, it appears like magic but really it is quite simple if you understand how different parts interact.
Once you are aware about how a typical system like this works, hopefully you can come up with more ideas to make use of the technology.
What Do You Need?
What appears to be magic actually is a set of tools and electronic devices working together. Each of them is able to communicate with the device next or before it.
There are a few components that work together in the light switch scenario:
- A computer system with controlling software. Obviously the computer has to be on for it to accept messages and to send them to the right devices. Smart home devices also have programmable controller and remote so signals could also be sent from this remote instead of a computer.
- A hardware controller. You need an electronic circuit that is able to receive signals from your computer (either via serial or USB port) and respond to it. It can be as simple as an on-off switch. If the device includes support for dimming lights, you will be able to extend the feature to dim instead of just turning on and off. As you see, the controller plays a critical role here.
- The controlled object. In this case, it is a light. There is nothing special about the object. Just that the signal from the controlling device — most likely computer — instruct the controller to do something that in turn do whatever it is programmed to do to the object.
- Communication mechanism. The last part of the system is a communication mechanism that lets you send signal to the computer system.
There are many ways to send instruction signals to your computer. Some email clients are able to filter subject line or content body and then run custom command. That means you can control and execute the controlling software wherever you have an email client.
An alternative would be posting a Twitter message (via cellphone or any Twitter client). Using Kwiry and Jott, you may even use your voice to post to Twitter. Ping.fm lets you use cellphone, instant messaging services, and others to send your message to Twitter.
Of course, you are not limited to Twitter. As long as you can fetch the data and process it later with your computer, you can use it as a communication mechanism.
I bet you can come up a few other options right now, can’t you?
How to Control Bedroom Light with Twitter
As a simple example, based on the model above, allow me to explain how to control the light with your cellphone and Twitter.
First of all, the setup requires a controller like Insteon PowerLinc Controller. The controller is able to connect to the computer via a USB interface, which in turn sends signal to a light dimmer. Setup is necessary to identify the device you want to control.
That’s for the hardware and controller part. The next thing is to find a way to setup the software so it sends signal to the controller. iLink Insteon scene management software is available under Linux with both graphical and command line interface.
With the command line version, you can type in command and instruct the controller to send the appropriate signal to the dimmer. Once that works, you need to automate the command.
This is when Twitter plays a role. With the published RSS feed, a simple script can be used to poll the RSS on a regular basis — such as every second. Based on the content of the tweet, the script execute the appropriate command to turn the light on and off.
Of course, you may want to setup a separate Twitter account just for this to avoid confusing your followers with your home automation command.
If you need real-time response, Twitter may not be suitable for this application because that means you have to rely on Twitter and the speed of which it updates the RSS feed. However, controlling devices via Twitter sounds just cool.
Note: Yes, with such setup, you can also send an instruction to turn the light on and off using your instant messaging client if you set that up first, such as using ping.fm.
Possible Applications
Imagination is the limit when it comes to applying this setup to other things. Switching the light on and off may just be the easiest application.
Here are some other ideas to start with:
- Turn another computer on and off. Shutdown can be done with the shutdown command, available in both Windows and Linux. I’m sure there is a similar function with Mac-based computer as basically it is UNIX-based. Turning on the machine is a bit tricky though. But one possible idea would be to enable wake up on LAN feature, both in the motherboard and the BIOS and then trigger the data packet through another computer.
- Brew coffee. Isn’t it great if you are able to turn the coffee machine on so it starts brewing coffee even before you get off the bed? A simple on and off electric circuit can help you. It works pretty much like the light switch scenario. Now even if your coffee maker doesn’t come with a programmable timer, you can have a cup of your favorite coffee ready before you walk out of your bedroom. Of course, the coffee maker has to be loaded with coffee and water and setup in a way that it automatically runs when it is powered.
- Play a song / music / recording. Wouldn’t it be nice if you could come home with your favorite music welcoming you? How about recording your voice and then play it back when someone else in the room? Many media players allow you to run them via command line and specify the name of the music or media files for playback.
- Run software program. It is possible to instruct your computer to execute certain software program, such as performing data backup to another partition or even to another host.
- Adjust room temperature. This can be as simple as turning the air conditioner on or off. More advanced options can be made available if the software supports them.
Basically what you can do depends on the controlling software and hardware.
Home automation is quite a popular topic recently. Thanks to the Internet and various communication protocols, now controlling various devices become easier, although some of the solutions are less elegant than others.
This post may not be particularly useful for mission critical task, but I think you’ll agree it makes a fun project for the weekend.
Leave your ideas and thoughts about it below.
Hendry Lee helps bloggers overcome strategic and technological challenges in starting and growing their blogs.
Twitter is an awesome tool for blog promotion, but how does Twitter marketing work? Read the article to find out. While you are there, download your free blogging eBook and subscribe to the blogging e-course where he reveals his secret about blogging and content writing!
Follow Hendry on Twitter (@hendrylee).

@ScottWilliams
You are kidding me… Right! Sweetness!
The power of twitter is endless!
@jcolier
What a great use of technology! The tough part is integrating the hardware into everything you want to control, but, once you have that – the possibilities are great!
Now if I could get twitter to help my kids do their homework…
@ramartijr
Back in the 90’s we remodeled a house here in Connecticut with an electronic strike plate on the front door. The idea is old but the list of available devices to connect to is rapidly growing.
@BrandMover
Great idea! My PLC controller has even an email server, so I can trigger the air conditioner with twitter or by an email command.
@ModernPainter
I’m going to hook Twitter up to my coffee machine:)
@wpdude
I’m gonna be run out of Cyberville on a rail but really why !!!!!
I’ve downloaded the latest patch to my hand called a finger and I use it to switch off the lights.
I get that you can tap into the API to use a tweet as an activator for, well, whatever but there are 101 other ways to do this.
There I’ve said it I’m officially a ludite.
@thebenchs
Greattt I would like this one Play a song / music / recording. like be in a dinner whit you loved one in my case my wife, and that suthing sung like our firts sung begging to play its owul dbe souch a great thing.
Than you for the gooodd post.
@GrahamRichards
Seems an awful lot of hassle to do something so simple that could easily be done with a cheap electric timer switch! Seems more like horses for courses, or should that be gadgets for geeks?!
Graham, I think it’s a sign that this industry is still in its infancy. Personally, I don’t think those examples above are particularly useful, but they demonstrate what could be done with technologies. At least, they are cool once they are setup.
The product itself is not so hard to install. It may come with a remote control. It is the software and computer parts that are harder. For instance, you can post to Twitter via many methods, but how to pull the data and translate them into instructions are not so easy without understanding in simple programming language.
Those are certainly going to change in the future.
Neil, I agree with you. For the bedroom light scenario, I’d prefer switch off the light with my finger. No big deal. But it is not the intention of this article.
BrandMover, that certainly is an interesting application.
Richard, you’re right. I can’t wait to see more applications in the future. We can only expect things become easier and faster (to set up) and more reliable.
@sekhonharshit
Interesting concept Hendry! The merit of the idea is accentuated by the fact that you could be sending the instruction via your mobile phone (twitter sms). However, it would be good to have a sort of push based system to avoid overloading an embedded system with periodic processing wastage to poll for instructions. Just a thought!