Bluetooth Controlled Outlet (Home Automation)





Introduction: Bluetooth Controlled Outlet (Home Automation)

Have you ever left the house and wondered if you forgot to turn off the lights or the TV? Or been driving home in the dark and wish the lights would be on before you get in the house with you hands full of groceries. A simple solution I have found is to create your very own smart outlet! A cheaper solution than leaving your lights on and easier than walking in the dark.

Home automation is a relatively new idea that security system companies are adding to their packages. This could prove to be expensive if you own an old home or impossible if you rent or live in a dorm room. One night I was laying in my bed in my college room and wished I had a way to turn off the lights instead of walking across the room flipping the switch and stumbling across my messy floor. While I laid in my bed that night I had the bright idea to see what other people were doing on YouTube to see how hard it would be to control my room with my phone. Imagine your galaxy phone (or iPhone, if your one of those people) being able to act as Jarvis from Iron Man. Here is a overview video of home automation; What is Home Automation?

Step 1: Materials and Parts

My project quickly changed from controlling my entire apartment (which would require a lot of parts and cutting of university wire, which would be frowned upon) to a very simple portable smart outlet. If I can learn how to control one outlet I can replicate the project into a full scale home automation project in a future house. For a college student this is perfect because I can turn my fan on lights off with out having to get out of bed. One thing I learned freshman year is that the single light you have in the middle of the room provides a very harsh light. A simple solution is to hang Christmas lights up around the room, using command hooks (these wont pull the paint off the walls and cause you to pay to fix it or loose your deposit). I did not want to start cutting the heads off my extension cords or from my fan so I decided to buy a new outlet that I can plug the cords into and wire directly to my relay board. The current version of my smart outlet uses the following parts:

Step 2: Wiring





I went to Lowes and bought an extension cord, mine was about 10' if I remember correctly. Using a pair of wire cutters I cut the extension cord in two 5' sections. You will use the male end to wire into the smart outlet, and the female end is your extra wire for the relay board and wiring to the outlets. I used the black wire to connect to relay board. Since I have two outlets I first twisted the two ground wires and the ground coming in together and put a wire nut on them (I suggest also wrapping in electrical tape), than attached to the outlets. I did the same thing for the white (hot) wire. Here is the tricky part, wiring to the relay with the black wires. First attach the incoming neutral wire with two extensions like you did for the previous wires. Make sure these extension go into the middle position of the relay triplet. This is pretty standard from what I have seen from setting up relays. Than attach two more extensions to the NORMALLY OPEN parts of the relay triplet (unless you want whatever is plugged in to turn on if the system restarts). The two extensions you now have get attached to the outlet.


This wiring is to your arduino, this should come fairly easy to those who have attached anything to their arduino via the digital ports. Look at the picture above for a guide.

If you are ready to put everything in the enclosure you will need to attach the bluetooth chip now as well. This is even more straight forward than the relay board.

Step 3: Code

What I would suggest doing first is to buy the relay board along with the arduino because this is about the only part that could go wrong for the code aspect. I bought mine from ebay and used a relay test code I found on Arduino's website. When testing you can verify functionality visually and you should hear the relay click when it engages. Here is my test code;

/* YourDuino Example: Relay Control 1.10
Handles "Relay is active-low" to assure no relay activation from reset until application is ready. *

*-----( Import needed libraries )-----*/ /*-----( Declare Constants )-----*/ #define RELAY_ON 0 #define RELAY_OFF 1 /*-----( Declare objects )-----*/ /*-----( Declare Variables )-----*/ #define Relay_1 7 // Arduino Digital I/O pin number #define Relay_2 8 #define Relay_3 9 #define Relay_4 10

void setup() /****** SETUP: RUNS ONCE ******/ { //-------( Initialize Pins so relays are inactive at reset)---- digitalWrite(Relay_1, RELAY_OFF); digitalWrite(Relay_2, RELAY_OFF); digitalWrite(Relay_3, RELAY_OFF); digitalWrite(Relay_4, RELAY_OFF); //---( THEN set pins as outputs )---- pinMode(Relay_1, OUTPUT); pinMode(Relay_2, OUTPUT); pinMode(Relay_3, OUTPUT); pinMode(Relay_4, OUTPUT); delay(4000); //Check that all relays are inactive at Reset

}//--(end setup )---

void loop() /****** LOOP: RUNS CONSTANTLY ******/ { //---( Turn all 4 relays ON in sequence)--- digitalWrite(Relay_1, RELAY_ON);// set the Relay ON delay(1000); // wait for a second digitalWrite(Relay_2, RELAY_ON);// set the Relay ON delay(1000); // wait for a second digitalWrite(Relay_3, RELAY_ON);// set the Relay ON delay(1000); // wait for a second digitalWrite(Relay_4, RELAY_ON);// set the Relay ON delay(4000); // wait see all relays ON //---( Turn all 4 relays OFF in sequence)--- digitalWrite(Relay_1, RELAY_OFF);// set the Relay OFF delay(1000); // wait for a second digitalWrite(Relay_2, RELAY_OFF);// set the Relay OFF delay(1000); // wait for a second digitalWrite(Relay_3, RELAY_OFF);// set the Relay OFF delay(1000); // wait for a second digitalWrite(Relay_4, RELAY_OFF);// set the Relay OFF delay(4000); // wait see all relays OFF

}//--(end main loop )---

//*********( THE END )***********

Because I am using a Bluetooth chip to connect my phone to the arduino the code is easy to grab from any website that has a corresponding app that is compatible with your phone. I found ArduDroid, a very user friendly website that steps you through the code for the bluetooth. I suggest reading this website and using his code and his app on the google play store. Thank you Hazim Bitar for making this easy to follow website!

Step 4: Conclusion

So I have concluded that this is a fairly easy project to do and a fairly cheap educational experience. I can lay in bed now and turn my lights off at night and turn my fan on so I can fall asleep. I have been using for a few weeks before writing this and I have not burnt the apartment down with this project and I have confidence to leave it plugged in while I am not in the building. In the future I want to add the ability to connect the arduino to the internet via WiFi or Ethernet. This will allow me to turn my lights on before I get into the apartment (Bluetooth range) and monitor what is on and off from where ever in the world I am located. Keep posted for updates, changes and adjustments! Please point out anything that needs to be addressed, changed, or altered. This is my first post, so please be easy on me!



    • Clocks Contest

      Clocks Contest
    • Creative Misuse Contest

      Creative Misuse Contest
    • Water Contest

      Water Contest

    25 Discussions


    2 years ago

    How do you power the DC components?? Did I miss that?

    2 replies

    The Arduino is powered by a ac/dc box just like what you use to charge your cell phone. This provides the power to the blue tooth module and the relay board.

    Were you able to fit that box into the outlet box?

    I want to start My Small bisuness on home automation system usimg arudino Need your Permmosion


    2 years ago

    Hey there! I'm actually a college student myself, and a writer for the site I'd definitely like to build one of these myself with my own take on things (I'll be trying to make a single self contained unit in an enclosure, just two outlets controlled independently). With your permission I'd like to write my own How-To to post on AllAboutCircuits and link to yours for reference. Let me know!

    1 reply

    Go for it! I'll be looking for it than!

    This provides absolutely no isolation from the mains except via the relay. If the relay fails and shorts internally to the 5v your Arduino will be at 120V on the VCC supply line because the opto-isolator is not being used correctly (VCC on both sides of the opto-isolator making it useless). You need a separate 5v supply on the JD-VCC pin instead of the jumper.

    great, but have u ever considered buying a 10 dollar 3 remote switches pack with a hand transmitter? Admitted you cannot switch those with yr phone but some have a hand transmitter for ona keyring.

    Still can use those for your future house and with an arduino as base staion you would be able to control them with yr phone, your TV remote control and even over the internet or with the original transmitter. All without cables.

    Having said that, still a great instructable

    3 replies

    I like your idea. Bluetooth cannot be operated beyond 20 feet. Remote control is better.

    Bluetooth can operate out to 100m with Class 1 BT devices (all transmitters must be class 1).

    100meters with open line of sight. A wi-fi can go around the world. Operating with bluetooth is a waste of money.

    Awesome job and great 'able. One correction: X10 has been with us since 1975. See


    2 years ago

    Great instructable, easy to follow. I've saved it so I can build it at some point (if I get free time lol)

    *noob warning* I like the idea of incorporating this into a home theater setup but I wonder could it be controlled via infrared instead of Bluetooth? Also, I'd probably add more relays for more equipment (like I said total noob). Also, before anyone gets concerned, I wouldn't be using something like this to run retro game consels, one at a time so the amperage would never be excessive.

    1 reply

    You can totally add more relays to the design, I just stuck with two because I am limited on space and only need two outlets now. When I own my own home, I will be incorporating this idea in.

    If you have any "noob" questions, ask. Rather be safe than sorry.

    I would love to be able to turn the lights on before I get home! It would be great to see more photos of your steps/process. Great first instructable!

    2 replies

    Easier way is to buy timers and plug in lamps for about $8.00.

    That would work if your on a fixed schedule. Like my grandparents have lights around the house that turns on around dinner time to prevent theft.

    Being a college student, bed time is really any time. Some nights i am asleep by 12, and others 3 am. So this allows me to just control on times when i need them.


    2 years ago

    Are you in north america? I know it's different other places but white is neutral in USA not hot. black is hot here. it may not apply to where you are so it's not a mistake but a wiring novice may misunderstand your guide.

    Also a small safety hint for your gang box. leaving the guts open is a big electrical no no. I would find a small price of wood to cover that open part.

    An in line 10 amp fuse in your hot line may also save your expensive relays if you did plug in too much amperage.

    One last tip. A romex wire clamp will help hold your 120v line into the box much more securely. It would be very dangerous for that to get pulled loose and shock or start a fire.