Tuesday 17 November 2015

Control your home using Android Voice Recognizer with Arduino

Home Controller :D

Sebarang pertanyaan/pembelian/bantuan boleh dm saya dia twitter eh:
twitter.com/zakimuslim_


I have a problem during uploading test run video on my blog. Feel free to watch on my FB!









Hardware:

-Arduino Board
-HC06 Bluetooth receiver
-Smartphone (Android)
-Relay, 5VDC
   here types of relay that you can use. Relay the most important component in this simple project.
   Choose the right spec!

   5VDC / 10A / 240VAC


Relay module.



Circuit!

Some photos that can helps you :D
In my video i use "by pass" concept. So i can ON/OFF using switch and smartphone!



                                                     Connect bluetooth receiver like this!
                                        Vice versa, so Arduino & HC06 can communicate each other.
                                                           TX > RX, then RX > TX




Line that i've bold is 240VAC.
Beware, high voltage/current!




                            Sorry i can't draw the circuit in computer. Just by hand. Sucks!









Arduino Coding!

Directly Download Here


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


String incoming;

void setup()
{
  Serial.begin(9600);
  pinMode(8, OUTPUT);   //set pin 8,9 as output. where relays connected
  pinMode(9, OUTPUT);
}

void loop()
{
  if(Serial.available() > 0)
  {
    incoming = Serial.readString();   //check what your smartphone send to arduino
    if(incoming == "hi")     //<<<< change here. change words in quotes.   if you say "hi" to your smartphone pin 8,9 will turn HIGH
    {
      digitalWrite(8, 250);
      digitalWrite(9, 250);
      
    }
    else if(incoming == "goodbye")    //<<<< change here. change words in quotes.  if you say "goodbye" to your smartphone pin 8,9 will turn LOW
    {
      digitalWrite(8, LOW);
      digitalWrite(9, LOW);
    }

    else if(incoming == "daylight")   //<<<< change here. change words in quotes. if you say "daylight" to your smartphone pin 8 will turn LOW (turn lamp OFF)
    {
      digitalWrite(8, HIGH);
    }

    else if(incoming == "night")  //<<<< change here
    {
      digitalWrite(8, LOW);
    }

    else if(incoming == "hot")   //<<<< change here
    {
      digitalWrite(9, HIGH);
    }

    else if(incoming == "cool")  //<<<< change here
    {
      digitalWrite(9, LOW);
    }
  }
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Code Explaination.

String incoming;
-store text that your smartphone sends in string.

Serial.begin(9600);
-
Serial buadrate.

pinMode(8, OUTPUT);
-Set pin 8 on arduino board as output pin. where relays connected.

 if(Serial.available() > 0)
-Check if serial available or not.

incoming = Serial.readString();
-incoming is the words that you smartphone sends.

if(incoming == "hi") 
-check what words you've send from smartphone.

if(incoming == "hi")
    {
      digitalWrite(8, 250);
      digitalWrite(9, 250);
    }
-Check what you have send using your smartphone. If you send "hi" relay that connected on pin 8 and pin 9 will be triggered and lamp and fan will turn ON.






Smartphone Coding!

I use MIT APP INVENTOR to create this app. Its free, just create an account and start build own app here!
You also can import my code to edit in MIT APP INVENTOR.
Here link you can download my code and app that i've use in my video!



How to import .aia format to your appinventor IDE:


1. Click on "Projects"
2. Click on "import project (.aia) from my computer..."




3. After import the .aia file, you can see the app design in your appinventor IDE.
    Now you can change the design and label into your own language!



4. At the top right you can see the button "BLOCKS". Click it and you can see the code.





5. Once you finnished edit the app, you can click on "Build" to build the APK.



6. After that, copy the apk to your phone and install !!





How to use this app?

Turn on bluetooth on your smartphone.






Click on "Pilih Bluetooth" to connect your smart phone to the system.



Now select the bluetooth client. Click on HC06.






Click on "Sentuh" to start giving a command.




Your smartphone will print the text that he recognised on screen.




You also can send command by typing. Just tap on the textbox. Then click on "HANTAR" to send the command.




This app run on my Asus Zenfone 5 LTE  smoothly :D







DOWNLOAD LINK



File .aia; https://drive.google.com/file/d/0B3c_VPBO9Qq3M0FDQjRzang5bkk/view?usp=sharing