Arduino/Android - BLUETOOTH Home Control + APP - HC-06

Arduino/Android - BLUETOOTH Home Control + APP - HC-06 © CC BY-SA

Hello world! Today I made a Android APP to control 8 relays with Arduino using the HC-06 Bluetooth module.

  • 25,237 views
  • 3 comments
  • 18 respects

Components and supplies

Ph a000066 iso (1) ztbmubhmho
Arduino UNO
×1
2 x 1 channel Relay KY-019
×1
HC-06 Bluetooth Module
×1
11026 02
Jumper wires (generic)
×1
Power cables + lamp sockets
×1

About this project

Hello world! Today I made an Android APP to control 8 relays with Arduino using the HC-06 Bluetooth module. The video just shows 2, but I changed the app! You can control 8 devices/lights with it. I created the APP and its available open source for a small favor.

Just contact me! The open source file is already set for 8 relays as well as the code that belongs to it.

DOWNLOAD THE APP ON GOOGLE PLAY! (english version only)

Step 1: Parts list

Just simply wire everything up like the schematic and upload the code.

(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, I used the RobotDyn uno a very good copy with 7 analog pins.
  • 2 x 1 channel Relay KY-019 (You can add more if you buy the open source app)
  • Jumper wires set MM/FF/MF
  • Power cables + lamp sockets (optional, you can add any device instead of lamps)

Good luck!

(Check step 2 for instructions on how to rename your HC-06, This is optional!)

Step 2: How to change the name of your HC-06

What is needed?

How to connect the Programmer?

  • VCC to VCC
  • GND to GND
  • RXD to TX
  • TXD to RX

Lets get started...

  • Connect the USB TTL programmer to the HC-06
  • Plug in the USB and open up The Arduino IDE
  • Open the serial monitor.
  • Type "AT" without quotes. You should see a respond in the Serial monitor saying "OK"
  • Type "AT+NAMExyz" Sets the module name to “xyz” (Replace xyz with the name you want.) response should be OKsetname.
  • Type "AT+PIN1234" Set the pin to 1234 (replace 1234 with your desired pin) respond should be OKsetPIN For more info on changing baudrate etc. I included a PDF file. Good luck!

Code

BLUETOOTH_home_control.inoArduino
This code will work with the app i created for it to control relays.
You can build a home automation system with it, or control other devices.
/*
Author: Danny van den Brande, Arduinosensors.nl. BlueCore Tech.
This code will work with the app i created for it to control relays.
You can build a home automation system with it, or control other devices. 
I build it originaly for home control.
If you want the Code for the APP open source You can contact me @ contact@arduinosensors.nl
 */
int relay1 = 2;
int relay2 = 3;
int relay3 = 4;
int relay4 = 5;
int relay5 = 6;
int relay6 = 7;
int relay7 = 8;
int relay8 = 9;

String readString;

void setup() {
  Serial.begin(9600);
  pinMode(relay1, OUTPUT); 
  pinMode(relay2, OUTPUT); 
  pinMode(relay3, OUTPUT); 
  pinMode(relay4, OUTPUT); 
  pinMode(relay5, OUTPUT); 
  pinMode(relay6, OUTPUT); 
  pinMode(relay7, OUTPUT); 
  pinMode(relay8, OUTPUT); 
}

void loop() {
  while (Serial.available()) {
    delay(3);  
    char c = Serial.read();
    readString += c; 
  }
  if (readString.length() >0) {
    Serial.println(readString);
    if (readString == "1 ON")     
    {
      digitalWrite(relay1, HIGH);
    }
    if (readString == "1 OFF")
    {
      digitalWrite(relay1, LOW);
    }
    //relay2
    if (readString == "2 ON")     
    {
      digitalWrite(relay2, HIGH);
    }
    if (readString == "2 OFF")
    {
      digitalWrite(relay2, LOW);
    }
    //relay3    
    if (readString == "3 ON")     
    {
      digitalWrite(relay3, HIGH);
    }
    if (readString == "3 OFF")
    {
      digitalWrite(relay3, LOW);
    }
    //relay4    
    if (readString == "4 ON")     
    {
      digitalWrite(relay4, HIGH);
    }
    if (readString == "4 OFF")
    {
      digitalWrite(relay4, LOW);
    }
    //relay5    
    if (readString == "5 ON")     
    {
      digitalWrite(relay5, HIGH);
    }
    if (readString == "5 OFF")
    {
      digitalWrite(relay5, LOW);
    }
    //relay6    
    if (readString == "6 ON")     
    {
      digitalWrite(relay6, HIGH);
    }
    if (readString == "6 OFF")
    {
      digitalWrite(relay6, LOW);
    }
    //relay7    
    if (readString == "7 ON")     
    {
      digitalWrite(relay7, HIGH);
    }
    if (readString == "7 OFF")
    {
      digitalWrite(relay7, LOW);
    }
    //relay8    
    if (readString == "8 ON")     
    {
      digitalWrite(relay8, HIGH);
    }
    if (readString == "8 OFF")
    {
      digitalWrite(relay8, LOW);
    }
    //All on / off    
    if (readString == "ALL ON")     
    {
      digitalWrite(relay1, HIGH);
      digitalWrite(relay2, HIGH);
      digitalWrite(relay3, HIGH);
      digitalWrite(relay4, HIGH);
      digitalWrite(relay5, HIGH);
      digitalWrite(relay6, HIGH);
      digitalWrite(relay7, HIGH);
      digitalWrite(relay8, HIGH);
    }
    if (readString == "ALL OFF")
    {
      digitalWrite(relay1, LOW);
      digitalWrite(relay2, LOW);
      digitalWrite(relay3, LOW);
      digitalWrite(relay4, LOW);
      digitalWrite(relay5, LOW);
      digitalWrite(relay6, LOW);
      digitalWrite(relay7, LOW);
      digitalWrite(relay8, LOW);
    }
    //next
    readString="";
  } 
}

Schematics

Schematic
Bluetooth%20home%20control bb

Comments

Similar projects you might like

Bluetooth Control Multitap

Project showcase by gledel and 윤원호

  • 2,576 views
  • 0 comments
  • 5 respects

Arduino/Android - BLUETOOTH Multi Servo Motor Control

Project tutorial by Danny van den Brande

  • 34,084 views
  • 13 comments
  • 51 respects

Control Arduino Uno Using ESP8266 WiFi Module and Blynk App

Project tutorial by Adithya TG

  • 115,592 views
  • 19 comments
  • 72 respects

Control the Speed of Brushless DC Motor Using Bluetooth

Project tutorial by mohitmehlawat

  • 16,447 views
  • 3 comments
  • 25 respects

Arduino – Bluetooth 12 Channel Relay App

by TayfMavi

  • 7,029 views
  • 3 comments
  • 11 respects
Add projectSign up / Login