( Wrist-watch Enabled) Home Automation Via Twitter




This is an Instructable to make a Twitter controlled Home Automation system for your house in less than 7$ (Rs.450). This tutorial includes setting up Python, Arduino as well as Twitter to build your very own Twitter controlled personal assistant.

The main reason I built this is to turn on the AC and mosquito coils in my room before I get home, so that when i come home, the room is already cooled and free from mosquitoes. But this implementation works for about anything.

Reason for the use of Twitter is because of an already existing twitter Android Wear app. This helps me to tweet by speaking into my watch. That basically means, I control my house talking to my watch!

Usually a home automation system of this sort would cost hundreds of dollars and still be not as good. In this project you will be able to control the appliances in your house right from your watch(if you have an android wear watch like I do).

Be sure to check out the video for an insight.

What goes in?

1) A micro-controller (arduino or arduino clone will do)

2) A laptop (Windows preferably)

3) A relay Shield (optional)

4) Android Wear Watch* (optional)

Step 1: Python Installation

Firstly you will have to download the TwitterHouse.zip file.

NOTE: The zip contains files ONLY FOR WINDOWS and no other operating system. Sorry. Based on your operating system you will have to download the equivalent individual files independently.

Check if you have python already installed on your computer by following the command prompt instruction below. If not continue this step.

Once you have downloaded and extracted the zip file, install python-2.7.9.msi

Open Command Prompt from search and type in "python" and click on enter. You should see that.

Step 2: Twitter Application

This and the next step are important steps where you link twitter to python.

To do so, you'll have to first create a Twitter account(if you don't have one).

Once you're done with that, head over to https://apps.twitter.com/ and hit on "Create New App". Type in a name(any name will do), description(doesn't have to be detailed) and website(any will do) and Create your Twitter application.

Now you go to Application setting and under Access level click on modify app permissions and change that to Read and Write, Update settings. Then click on the Keys and Access tokens tab and note down your Consumer Key and Secret. and scroll down to "Create my access token". Note down your Access token and access token secret as well.

Now you're all set with Twitter's Application Program Interface.

Step 3: Python Twitter Integration

Go back to the folder you had unzipped the downloaded file. And unzip the file tweepy-master.zip

Once you're done with that, open CMD(command prompt) again and navigate to the location of tweepy.

To enter a file, type "cd" and then the file name. and to go to root directory type "cd \".

Once you are in the folder tweepy-master where the file setup.py is located, type in "python setup.py install ". Once its done installing. Close cmd and reopen it. Type


once python is opened, type in

import tweepy

If you get ">>>" then you have successfully installed tweepy on your computer. Congratulations.

I suggest you install pyserial-2.7.win32.exe now as well. This you can just install like any other normal executable installation.

Step 4: Arduino Software Setup

In the same downloaded and unzipped folder(TwitterHome), run the installation of arduino. (arduino-1.6.0-windows (1).exe).

Once you're done installing the Arduino IDE, connect your Arduino using the USB serial cable and start the IDE. Select the board you are using and port it is connected on.

NOTE: I am using an Arduino clone and hence my drivers had to be installed separately. If you are also using a clone, download and install the respective drivers too in case it doesn't detect.

Take a note of this port as well.

Now open the file TwitterHome\python-tweet\python-tweet.ino in the IDE. Compile and upload the code to your Arduino.

Now you are done with the coding part of the Arduino.

You may reward yourself with a cookie.

Step 5: Python Coding

This is the part where you may go wrong the most number of times. But don't worry. I did too, because I had to write that code you will use.

Back to the TwitterHome folder, there are 2 files, homeautomationon.py and homeautomationoff.py

This tutorial will show you what to do in one of them and you will have to repeat the same steps for the other file.

So first right click on the file homautomationon.py and click on "edit with IDLE".

Once the editor opens, first thing you'll notice are the comments throughout the code. These comments(## change or ## change optional) are the lines of code you will have to edit based on your preferences and your configuration. The changes are pretty straight forward but in case you have any problems, feel free to comment below.

All the things I asked you to Note down earlier will come in handy now.

Step 6: Hardware

This is the step where you can tailor the hardware to suit your needs.

This step becomes very simple if you have an arduino Relay shield, if not you can make one like I did and use it. The trigger of the relay shield is to be connected to the pin programmed in the arduino program you uploaded to your microcontroller.

Attach the appliance to your relay shield like you would do if you were to put a switch in its circuit. The arduino doesnt drive the appliance but simply acts as an ON/OFF switch. After you're done wiring up the shield and the arduino connect it back to your computer.

Step 7: Watch Integration

This is the most fun and simplest step. Download Bunting on your phone and it should appear on your watch.

You are all set. :)

Step 8: Magic

Go to the python IDLE editor window that the program you have edited is in, and click on F5. You should see a new window pop up and it will display the contents of any tweet containing the keywords you have specified. When that keyword is detected, python will send a message via serial to your arduino to turn ON/OFF the appliance.

And now you can brag about your personal assistant on twitter. *drumroll* You can try it out by either tweeting on your watch (or any other device). When you tweet with the keyword, your PA will also tweet back to you based on the process undertaken.

Ta-daaaaaa. *bow*



  • Colors of the Rainbow Contest

    Colors of the Rainbow Contest
  • Beauty Tips Contest

    Beauty Tips Contest
  • Sensors Contest

    Sensors Contest

18 Discussions

Muhamad SyimirS

3 years ago

Hello, is it possible, that i use only mobile to tweet rather than using wrist watch? thank you!

Muhamad SyimirS

3 years ago

Hello there! your project is super damn cool and i'm using it as reference to my final year project! I'm a beginner to arduino! Is it necessary to use the wrist-watch? How to make it works by just tweeting from the phone?


4 years ago

Nice going bro! Will try it some day!

adheshG S Chakravarty

Reply 4 years ago on Introduction

Assume that the relay is a mechanical switch and connect it like you would for it. Or disconnect the wall switch for it and connect the two wires you removed to the relay. Be careful with the current that your AC draws and the amount your relay can withstand.


4 years ago on Step 5

I survived all the way till the last step then this props up when i run it!

Traceback (most recent call last):

File "C:\Users\Gagan Bhat\Downloads\TwitterHome\homeautomationon.py", line 22, in <module>

ser = serial.Serial(usbport, 9600, timeout=1) ##change optional

File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 38, in __init__

SerialBase.__init__(self, *args, **kwargs)

File "C:\Python27\lib\site-packages\serial\serialutil.py", line 282, in __init__


File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 66, in open

raise SerialException("could not open port %r: %r" % (self.portstr, ctypes.WinError()))

SerialException: could not open port 'COM3': WindowsError(5, 'Access is denied.')


1 reply

Reply 4 years ago on Introduction

Did you connect your arduino right? Go over to the arduino IDE and check the port its connected on. Change COM3 in the source code to the right port. If that doesnt fix it then write a small program and check if serial connection with your arduino works alright in the arduino IDE.


4 years ago on Step 3


Whenever I type Python or Python setup.py install then it says that python is not recognized as an internal or external command

1 reply

Reply 4 years ago on Introduction

From your next comment I'm guessing you figured a workaround for this...


4 years ago on Step 8

It was an enjoying read :)
Sounds quite interesting , I might try it some day . Is it possible for u to say please on ac and set it at 20 degrees ? Just curious ....

1 reply

Reply 4 years ago on Step 8

Thanks. I'm still working on that. I will edit and post the improvisations add soon as possible. :)