Introduction: Arduino Bluetooth HomeControl (Android)

Hello

This is a device i made to control 2 outputs over a android app.

you can connect lights, coffee machine, everything is possible.

I made it with 3 power sockets(Outlets)

2 sockets is being powered by the same relay, and 1 by it self.

You can use the HomeControl as a normal power outlet, when the Arduino is of. When you turn Arduino/HomeControl on, then it will only power things turned on in the android app.

I made it this way so it is possible to use it as a normal power socket.

Step 1: Things You Will Need:

  • 1 x Arduino Uno, Nano, Mege or Clone (I use a Nano clone from ebay)
  • 2 x Relay 5V
  • 2 X Green LED
  • 2 x 250 Ohm Resistor
  • Bluetooth transceiver HC-05
  • Breadboard
  • Dupont wires
  • Cable
  • Cable connectors
  • Box to fit your project in. (i used a old phone box, plastic box will be better)
  • On/off button.
  • Power socket

  • Android phone or tablet

Step 2: Prepare the Power Socket

(I made a little mistake. I also cut over gnd, you dont need to do that!! It will only give your self more work)

The single socket we call PowerOne
The double socket we call PowerTwo

First take the socket apart. cut the power cable over, save the male plug, we need that for later.

Now you need to cut the + connection over. we do that, because we want to separate the

connections, so we can control them individually.

Now drill a hole near PowerOne, Strip a wire and solder it to the + and to the gnd. on PowerOne.

PowerTwo is already connected by the wire from the start. so leave that as it is.

Now put the power socket together again.

you goal is to end up with a power socket that has a cable for PowerOne and for PowerTwo.

Step 3: Connect Relays to Power Sockets

Now take the relays. I made a little bracket of 4 bolts and cardboard.

Place power socket and relays in you HomeControl box. make the connections

1- Not in use

2- This is where the power comes from. (220V) Connect the male plug + to here. (that one from from earlier) in here.

Also take a jumper wirer and connect both relays from 2 => 2.

3- Here you connect the + to the PowerOne / PowerTwo socket.

Step 4: Connect Things to the Arduino

Ardiono pins:

Pin 13 => Relay PowerOne

Pin 8 => Relay PowerTwo

Pin3 => LED PowerTwo

Pin 2 => LED PowerOne

Step 5: Finish the Project

Now we are ready to put everything in the box and paint it for better looks

Step 6: Upload Sketch to Arduino

// Control 2 relays over bluetooth//

int powerone = 13; // PowerOne relay to arduino pin 13 //

int powertwo = 8; // powertwo relay to arduino pin 8 //

int led1 = 2; // led powerone //

int led2 = 3; // led powertwo //

int state; // for bluetooth

void setup() {
pinMode(powerone, OUTPUT); // set all pins as Output pins//

pinMode(powertwo, OUTPUT);

pinMode(led1, OUTPUT);

pinMode(led2, OUTPUT);

Serial.begin(9600);

}

void loop() {
if(Serial.available() > 0){ // if there is data from bluetooth //

state = Serial.read();} // put in to state //

if (state == '2') { // value send from app//

digitalWrite(powerone, HIGH); // Turn on powerone by setting the pin to HIGH//

digitalWrite(led1, HIGH); // Turn on led1 by setting the pin to HIGH//

}

else if (state == '1') { // value send from app//
digitalWrite(powerone, LOW); // Turn off powerone by setting the pin to LOW //

digitalWrite(led1, LOW); // Turn off led1 by setting the pin to LOW //

}

delay(100);
if (state == '4') { //value send from app//

digitalWrite(powertwo, HIGH); // Turn on powertwo by setting the pin to HIGH //

digitalWrite(led2, HIGH); // Turn on led2 by setting the pin to HIGH //

}

else if (state == '3') { // value send from app //
digitalWrite(powertwo, LOW); // Turn off powertwo by setting the pin to LOW //

digitalWrite(led2, LOW); // Turn off powertwo by setting the pin to LOW //

}

delay(100);

}

Step 7: Make Android App

I used MIT App Inventor to make the app.

It is simple to use. But it is not the best to make good looking apps, its hard to arrange the buttons, if you want them to have different sizes. And if you want them with pictures.,

I learned to make apps from www.randomnerdtutorials.com/ He have many really good tutorials. please take a look at the website.

http://randomnerdtutorials.com/how-to-use-app-inve... this is a link to hes tutorial of making the app.

I made some changes, from the app he is making. I changes the buttons with canvas, and imageSprite.

I did that, so i could change color on the button. It can be done by placing 2 imageSrite the same place. Now you can set the Z axis on them. so if you press the button, it goes from 0,0 to -0,1 on the Z axis. by that one pictures is shown and the other one is hide behind.

Maybe it can be done with buttons also, but i dont know how yet. but this work fine for me.

In the app we are sending Dec to arduino. the arduino sketch is reading char.

That means that we are sending the number 49 in the app. but in the sketch it is 1.

Look at this, there is a table that shows what number you can use. if you want to make changes in the app. and in the sketch.

https://simple.wikipedia.org/wiki/ASCII

Step 8: Test Your HomeControl

Time for testing.

Remember to turn the HomeControl on before connecting thing to it. Because when its off, the power plugs is working like normal.

when you connect it to your phone then the sockets is turned off, and you can control them over you phone.

When you push the bluetooth button, then you come to a screen where you can connect to the hc-05.

After connection it is ready to use.

Step 9: How to Install the App

When you have downloaded the zip folder.

1. Go and find the .apk file in the app folder.

2. Now connect your phone by usb cable to your pc.

3. Move the .apk file to a folder on your phone. I normal move it to the download folder.

4. Open file folder on your phone. find the download folder and find the .apk file. select it and install the app.

maybe you have to change settings for installing apps that is not from the google play. but it comes up automatic.

5. Now you are ready to take control over you house

Step 10: Downloads

Download Sketch and App here.

Step 11: Done

First please let me know if you find any problems in the sketch or in the app so i can edit them. thanks

You can make it better by adding on more relay so you can control all power sockets individually.

And maybe use WIFI for the connection. better reach.

Thank you for watching.

And please show me your project or if you make some improvement let me know.

Please double check your connections, so you dont burn anything, of get electric shocks.

Be careful and always only touch the wire when power is off.

Im from Denmark so if my english is not understandable, please send a message and i will try to explain it.

Or if you have any other questions feel free to ask.

First Time Author Contest 2016

Participated in the
First Time Author Contest 2016