Bluetooth Relay Control Step:5,6,7

Android controlled smart home

Step 5: Software
  1. Download HC-06 Control.apk  Android app from here Link
  2. Copy and download "HC-06 Control.apk" in your smart phone
  3. Check the download from unknown sources setting before installation on your phone. Allow download/ install from unknown sources
  4. Install the app.
  5. Download Code in Arduino Board
  6. While Downloading Arduino Code Disconnect the Bluetooth module
Arduino Code:

/*
 www.circuits4you.com
 blog.circuits4you.com
 This code demostrates Bluetooth based Device control
 It controls Four Devicess through Relay 
 This example code is in the public domain.
 */
 
 //Define Relay Connections
 #define Relay1  9
 #define Relay2  10
 #define Relay3  11
 #define Relay4  12
 
int inByte = 0;         // incoming serial byte

void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);     
  pinMode(Relay1,OUTPUT);  //Relay Pins in Output mode
  pinMode(Relay2,OUTPUT);
  pinMode(Relay3,OUTPUT);
  pinMode(Relay4,OUTPUT);
}

void loop() {
    if (Serial.available() > 0) {
          inByte = Serial.read();
          
         switch (inByte) {
          case 0x03:
              digitalWrite(Relay1, HIGH);  //Relay 1 on when inByte equals A
            break;
          case 0x04:               
                digitalWrite(Relay1, LOW);  //Relay 1 off when inByte equals B
            break;
          case 0x05:
              digitalWrite(Relay2, HIGH);  //Relay 1 on when inByte equals A
            break;
          case 0x06:               
                digitalWrite(Relay2, LOW);  //Relay 1 off when inByte equals B
            break;
          case 0x07:
              digitalWrite(Relay3, HIGH);  //Relay 1 on when inByte equals A
            break;
          case 0x08:               
                digitalWrite(Relay3, LOW);  //Relay 1 off when inByte equals B
            break;
          case 0x09:
              digitalWrite(Relay4, HIGH);  //Relay 1 on when inByte equals A
            break;
          case 0x0A:               
                digitalWrite(Relay4, LOW);  //Relay 1 off when inByte equals B
            break;
          case 0x0B:
              digitalWrite(Relay1, HIGH);  //All Relays ON when inByte equals 1
              digitalWrite(Relay2, HIGH);
              digitalWrite(Relay3, HIGH);
              digitalWrite(Relay4, HIGH);
            break;
          case 0x0C:               
                digitalWrite(Relay1, LOW);  //All Relays OFF when inByte equals 2
                digitalWrite(Relay2, LOW);
                digitalWrite(Relay3, LOW);
                digitalWrite(Relay4, LOW);
            break;            
        }

    }
}



Step 6: Power Supply Connections
  1. Connect +12V Adapter to Arduino

Step 7: Testing
  1. Turn on all setup
  2. Turn on Bluetooth on your phone and pair it with HC-06 (Pin 1234 or 0000)
  3. After successful pairing start the application
  4. You have done it…..

5. Connect your appliances to relay board




3 comments:

  1. How can i insert program to arduno,,,iam using arduno atmega 325 is it okay,,

    ReplyDelete
    Replies
    1. its ok any board will work only take care of proper connections

      Delete