Arduino Home control Bluetooth HC-06

Arduino Home control.

Hello world! Today i made a Arduino Home control Bluetooth HC-06 device with 2 relays and a hc-06 Bluetooth module
to use it as a voice control system. You can use this app to control it-> (CLICK HERE FOR THE APP) You can set any word in the code as long as the language of your phone recognizes it.

Schematic:
bluetooth voice control, Arduino Home control

(NOTE: the schematic show the relays connected to 3.3v
these should be connected to 5v, Only the HC-06 needs to be connected to 3.3v
)

Also make sure not to have the bluetooth connected when uploading the code!

Parts list:
Arduino uno.
HC-06 Bluetooth Module. (You can also use the HC-05)
2 x 1 channel relay KY-019
Jumper wires set MM/FF/MF
Lamp socket + Power cable (Optional)

Code:

/*
Author: Danny van den Brande, ArduinoSensors.nl, BlueCore Tech.
Voice control for 2 relays. You can add more relays if needed.
This code only controls 2 lamps or devices. Just copy/paste the "COPY/PASTE SECTION" that i made.
 */

String voice;

#define relay1 2    
#define relay2 3 // You can add more relays if needed like this.
//#define relay3 4 // Just uncomment these lines to use more relays 
//#define relay4 5 // i set up 3 extra for you.  

void setup()
{
  Serial.begin(9600);            
  pinMode(relay1, OUTPUT);  
  pinMode(relay2, OUTPUT);//uncomment these lines when using more relays.
//  pinMode(relay3, OUTPUT);
//  pinMode(relay4, OUTPUT);     
}
void loop()
{
  while(Serial.available())   
  {
    delay(10);                 
    char c = Serial.read();   
    if (c == '#'){
      break;                   
    }
    voice += c;                //Means voice = voice + c
  }
    if (voice.length() >0)
    {
      Serial.println(voice); 
      if(voice == "*alles aan"){ //dont remove the *
        digitalWrite(relay1, HIGH);// This will turn on everything.
        digitalWrite(relay2, HIGH);
//        digitalWrite(relay3, HIGH);
//        digitalWrite(relay4, HIGH);
      }               
      else if(voice == "*alles uit"){// This will turn off everything.
        digitalWrite(relay1, LOW);
        digitalWrite(relay2, LOW);
//        digitalWrite(relay3, LOW);
//        digitalWrite(relay4, LOW);
      }               
      else if(voice == "*woonkamer aan"){ //you can fill in whatever you want.
        digitalWrite(relay1, HIGH);
      }
      else if(voice == "*woonkamer uit"){
        digitalWrite(relay1, LOW);
      }
      // COPY/PASTE SECTION BEGIN
      else if(voice == "*keuken aan"){    //paste from here to add more relays.
        digitalWrite(relay2, HIGH);
      }
      else if(voice == "*keuken uit"){
        digitalWrite(relay2, LOW);
      }                                   //Paste to here to add more relays.
      // COPY/PASTE SECTION END

      voice="";
    }
}

Danny van den Brande

http://www.arduinosensors.nl

Programmer, Game Designer, 3D Designer, Web Designer, Graphic Designer. Jup this website looks crappy.. :) But enjoy the projects! Everything you need is here.

Leave a Reply

Your email address will not be published. Required fields are marked *