Introduction: DIY Android Home Automation Box

Here's a little show and tell of my Android controlled home automation box. It's a small extension box that's controlled by an Android smartphone. You can turn the individual outlets on by tapping a button from the app or use the speech recognition app, found from my previous tutorial. I've teamed up with my friends and built a custom app for out home automation prototype project. My former classmate/ fellow ible member "treyes4" built something similar.

__________________

It's just a prototype so don't expect much from this version. I assure that next version would be explained more thoroughly.

________________

I'll be gone for a while: I'll be posting a video once I get back from the international trade and business competition hosted by FedEx (school related). I posted this guide early, since the home automation contest deadline is due today. There's a lot of unexplained areas in this guide, without the prior knowledge, this project would be difficult to execute. Just ask questions below, I'll answer them through my phone. Once I get back, I'll edit and update this guide. Sorry for the inconvenience.

__________________


Step 1: Bill of Materials

If your having trouble in finding them, I'm sure RadioShack has all of them. If you want to buy online try searching on Amazon or DealExtreme.

Thing that you'll need:

- Android Phone & App

- Arduino UNO (a clone works fine)

- Low Power/ Switching Power Supply

- Dot Matrix Solderless Breadboard

- HC-05 Serial Bluetooth Module

- 2N3904 NPN Transistor (5x)

- 2.2k Ohm Resistor 1/4 (5x)

- 6V Relays (5x)

- Jumper Cables

Step 2: Find a Good Enclosure

I bought my enclosure from Alexan, a local electronics/ hobby store. This project is a prototype, the perfect enclosure would be an enclosure big enough to house an Arduino prototyping board and a small switching-PSU.

Step 3: Glue the Sockets Together

Align the outlets then use superglue to hold them temporarily. Hot glue can be used to strengthen the bond. After gluing, start to link a common rail. The linked rail work's like a common ground although this is AC ~ so it's not.

Step 4: Align & Measure the Sockets

Align the AC sockets together then acquire the dimensions of the array of sockets.

Step 5: Transfer the Measurements

Transfer your measurements by using a marker and ruler.

Step 6: Grind and Drill the Enclosure

Use your hacksaw or rotary tool to cut off the plastic that you've marked. Use a metal file to even out the edges.

Step 7: Construct the Relay Circuit

I constructed my DIY relay circuit. Obviously this is a complete prototype, I used a perfboard for mounting my components on. This is dangerous, exposed AC line can cause death through electrocution. Before attempting this project, be sure you're qualified to execute the task. My next version in the future would probably include solid state relays mounted on a custom PCB.

Step 8: Wire the PSU

The PSU will serve as your Relay and Arduino's power supply. I bought mine from ebay.

Specs: 12v (1 Amp)

Step 9: Upload the Sketch

/*Paste this on your Arduino's IDE

The BlackBox Arduino Author: Thomas Niccolo Filamor Reyes */ #include

SoftwareSerial mySerial(2, 3); // RX, TX

//these ladies shorten the script #define printer Serial.println #define reader mySerial.read

//fullString from android app //c is for the reader char fString [5], c;

//digital pins, uint8_t/unsigned char //to save memory of 8 bits/1 byte //normally I'd use an int (16 bit/2 byte), //but it limits value from 0 to 255 //no negative values unsigned char digital[5] = {8,9,10,11,12};

//*index of recorded character array uint8_t v = 0;

void setup(){ Serial.begin(9600); mySerial.begin(9600); //scroll through all digital pins listed as output for(uint8_t i=0;i<5;i++) pinMode(digital[i], OUTPUT); } void loop(){ //*index of recorded character array v = 0; //incoming bytes while(mySerial.available()){ //give her some time to recieve delay(10); c = reader(); //stop filling the chararray if # is encountered or // it goes beyond index 4 (5th value) if (c == '~' || v > 4)break; fString[v] = c; //increments index v++; } //if the index is greater than 0... if(v > 1){ printer(fString); //scroll through them for(int i =0; i<5; i++){ //I wish I could use bits instead here... efficiency if(fString[i]=='0') digitalWrite(digital[i], LOW); else digitalWrite(digital[i], HIGH); } } }

Step 10: Install the App

Step 11: Build & Install the Bluetooth Module

Connect the RX to pin #2 and the TX to pin#3

Step 12: Install the Arduino

Wire the Arduino to the other parts

Step 13: Screw the Cover Back on - Enjoy!

Your done, enjoy!

Comments

author
bushra.moni (author)2014-12-06

i m having a problem..... i have made the circuit nd now i m unable to fine the app to control it with my cell phone .....i donot knw the programing so i jxt copied it for ur link but app...... m jxt trapped plx help me its urgent as i hav to submit my assignment at my college

author
SOHAIBciit (author)bushra.moni2014-12-06

I had the same problem.
I am using this app instead:

https://play.google.com/store/apps/details?id=robo...

works great.

author
jueljp (author)SOHAIBciit2015-01-02

any difference made to the electronics/coding?

author
medgard789 (author)2017-02-28

Bro powede bang gumamit ng 4 chanel relay module, 4 lang sana gawin ko.

author
sohampatel (author)2016-12-28

one more help i needed how can i get .apk file of the app used in this project because on extracting the .rar file i am not able to get the .apk file which need to be install in android phone....pls help me out of this two problems

author
sohampatel (author)2016-12-28

can this project be done with Arduino UNO R3 (blue colour).

what changes i have to make in programing and pinouts connection when i am using arduino uno R3.

author
DharaniS3 (author)2016-10-02

itd be so good if we can time them on app

author
NeoRecasata (author)2016-09-19

Some site just COPY PASTED YOUR WORK!!!! -Click on this
I think it also copy pasted some(500 pages) more ibles. Can we report the site?

author
BrandonW86 (author)2016-08-23

I'll definitely be making this for my shed that'll be going up hopefully next summer. In the mean time, this will be used for some stuff in my house, and as a chance to get my hands dirty on app construction (I'm a software engineer by day).

author
ClintH15 (author)2016-08-23

You should update this as you had mentioned.

author
JoshB4 (author)2016-08-23

Could this be done with Ubuntu Touch instead of Android?

author
owiss (author)2016-08-23

the last image is great ! pravo!

author
Shivam gautam made it! (author)2016-06-08

It's my first project.....

temp_2050881860.jpgtemp_-208301404.jpgtemp_1420770389.jpgtemp_1900360329.jpg
author
MARWAN.LED (author)Shivam gautam2016-08-23

Please can you send project and code to me by my email.
Thanks and good job

author
MARWAN.LED (author)MARWAN.LED2016-08-23

Marwanled@gmail.com

author
dennyzulfikar (author)2016-08-20

you should consider to have some ventilation for your enclosure. AC/DC, both of them are easy to getting hot and melted.

and Fuse, don't miss to install that one.

author
brandonkehl (author)2014-08-05

Where did you get your power supply?

author
ASCAS (author)brandonkehl2014-08-06

I bought mine from eBay (stated on step #8).

author
Shivam gautam (author)ASCAS2016-02-21

can you please send me the circuit diagram ......and about psu model...at
sgm1081@gmail.com

author
mlakhwani (author)2016-02-03

hello, nice project. just few things to confirm:
1) can i use esp8266 to control it over lan ?

2)can i add 8 ch relay ?

thanks

author
mohsint1 (author)2015-12-10

bro can u plz upload the sketch that how u connect arduino + bluetooth + relays + PSU?? kindly email me plz... thanks

signorpositive2014@gmail.com

author
SOHAIBciit (author)2014-11-23

awesome instructable...
enjoyed making it ;^)

temp_-2143991314.jpgtemp_1646243402.jpg
author
VaibhavG11 (author)SOHAIBciit2015-11-03

hey awesome stuff
can u plzz give me the layout/circuit for whole system
thanks in advance
my email is - gargvaibhav1994@gmail.com

author

Hi Sir!! what sketch did u use? and how to use the AMR: Gestures apk?

author
VaibhavG11 (author)2015-11-03

hey awesome stuff
can u plzz give me the layout/circuit for whole system
thanks in advance
my email is - gargvaibhav1994@gmail.com

author
Maker Lab (author)2015-10-20

I like your design.But therse mising diodes to protect transistors.(if i write some words wrong im not from english speaking country)

author
RonC4 (author)2015-06-20

can i use arduino mega 2560, Relay module 4channel opto-isolated, and Bluetooth Module HC-06 (slave) instead of Arduino UNO, HC-05 Serial Bluetooth Module, 6V Relays. thanks. i love your project pls help me.

author
IshanP (author)2015-02-12

i just wanted to know weather or not i can use 5 of these instead of soldering the relays

http://probots.co.in/index.php?main_page=product_info&cPath=67_85&products_id=439&zenid=5f861de25d3ee0f7c45b6b5d7620a95f

author
jueljp (author)2015-01-02

how much watts per plug, i intend to use it to control some leds in my bedroom

author
ASCAS (author)jueljp2015-01-22

That would depend on the relay that you have selected.

author
LongJ (author)2014-12-30

Woah .... Major rookie mistake here. You MUST put a diode across those relay coils or you are going to get a reverse polarity voltage spike back through the driver transistor when the magnetic field of the relay coil collapses (This is the same effect switch mode power supplies use to generate lower, higher and opposite polarity voltages) A reverse polarity diode across the coil will spike that voltage to ground while doing nothing during normal operation. There are literally hundreds of examples of how to do this on the internet.

At least you have a transistor between the coil and the micro which helps protect the micro from the inductive kickback of the relay coil but you still need that clamping/snubbing diode. Think of it as an insurance policies that costs just a few pennies

author
ASCAS (author)LongJ2014-12-30

I did actually, I added a 1N4007 rectifier on each relay although I forgot to document it here.

author
LongJ (author)ASCAS2015-01-21

I'm not trying to be harsh here but you really should go back and add that to the documentation so those that don't know any better don't make the mistake of leaving them out. Maybe even a short blurb explaining why this diode is important (I stock 1n4004 in the same bin as my relays because to me they are a set) You obviously have some skills, you just need to polish them and I certainly don't want to discourage you. One thing my Grandfather who was a Master Electrician taught me when I was still in high school and still serves me well (And I'm a BSEE) to this day is:

The difference between a Master and a Journeyman is attention to detail .....

author
LongJ (author)LongJ2014-12-30

I'd like to add a couple of other tips. For those on 220/240V systems it doesn't matter which leg you switch but those of us in the US or other places with 120V systems you should switch the black or Hot wire NOT the white or neutral wire which is a big no no and a violation of Federal (and State) Electrical Codes. The reason being the white neutral wire is actually connected to the ground buss in the main service (breaker) box

Even if you are using a non-conductive case please use a proper 3 prong grounded plug, ground your power supply's case and make sure the safety grounds are run to all receptacles. Also I would put a fuse on the incoming AC line with a maximum 15 amp fuse.

Stay safe and have fun!

author
firefox21 (author)2014-12-17

Hi! I'm trying to do this as a project. Just want to ask, is the ac line be connected to the sockets? And where will the PSU be connected to? Thanks!!

author
tmaji12 (author)2014-11-03

having problem on app saying "socket creation failed". how to eliment this prob

author
tmaji12 (author)tmaji122014-11-03

plz help me its urgent..

author
Nikus (author)tmaji122014-11-23

I had the same problem but I solved it. You need to change in android code this:

private static String address = "30:14:08:15:20:57";

on address of your bluetooth module. You can check it in bluetooth settings on your phone.

author
SOHAIBciit (author)2014-11-14

How to Install the android app.??

I cannot understand, there are so many files. What to do?

Can you give step by step instructions.....

Thanks in advance.

author
morcosnagy1 (author)2014-11-14

Can you explain step 12 with some photos or how i can connect the others with arduino ? and why do you use the resistors in the arduino ?
i am sorry i can not understand this step

author
teguhoo7 (author)2014-11-05

how the existing scheme in step 8 and 7 ??
can you help me ??


author
mohamez (author)2014-10-12

how can i make the relay board ?

author
ASCAS (author)mohamez2014-10-27

By following the given schematic.

author
william.catchin (author)2014-10-27

why the RX-TX pin of bluetooth module connected to pin 2-3 instead of TX-RX pin in arduino board?

author
ASCAS (author)william.catchin2014-10-27

I reassigned the pins, because the BT module interferes with the arduino when I'm uploading a sketch.

author
OhYeahThatGuy81 (author)2014-09-29

Very nice!

How does it feel to be a TV star?

author
kimpoy.develles (author)2014-09-07

Hi Mr. Angelo!I'm planning to do your Home automation project as my school project..I'm wondering what sketch should be uploaded to the arduino board?its a bit confusing because there are 3 sketches and I don't know which sketch should be uploaded..thanks :)

author
Tezeusz (author)kimpoy.develles2014-09-21

is not a sketch, it's a tab :)

author
deba168 (author)2014-08-12

Congrats Angelo :)

author
ASCAS (author)deba1682014-08-13

Thanks and congrats to you as well, my friend! :D

About This Instructable

118,041views

1,236favorites

License:

Bio: Hi I'm Angelo! I am a 18 y/o college sophomore taking my majors in BS-ECE at the DLSU. I use my course as ... More »
More by ASCAS:Build A Bluetooth Boombox Speaker (from scratch) DIY Life-Size Phone Controlled BB8 DroidRig A Car Horn To Your Alarmclock!
Add instructable to: