Spread the love

 

This project illustrates how to interface a Bluetooth Module and IR reciever with Arduino Board and control the home appliances.
  • HC-05 Bluetooth to Serial Port Module

HC-05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial connection setup.

Serial port Bluetooth module is fully qualified Bluetooth V2.0+EDR (Enhanced Data Rate) 3Mbps Modulation with complete 2.4GHz radio transceiver and baseband. It uses CSR Bluecore 04-External single chip Bluetooth system with CMOS technology and with AFH(Adaptive Frequency Hopping Feature). It has the footprint as small as 12.7mmx27mm.

hc05

  • TSOP 1838 – IR receiver:

The TSOP1838 is an IR Receiver Modules for Remote Control Systems.

It has the following features:

  • Very low supply current
    • Photo detector and preamplifier in one package
    • Internal filter for PCM frequency
    • Improved shielding against EMI
    • Supply voltage: 2.5 V to 5.5 V
    • Improved immunity against ambient light
    • Insensitive to supply voltage ripple and noise.

tsop

DEMO :

demo

CIRCUIT DIAGRAM :

Connections of HC-05 with Arduino :

bluetooth

Connections of Arduino with Relay :

connection with relay

CODE FOR PROJECT :

#include <IRremote.h>
#include<LiquidCrystal.h>

//Pin Description

int RECV_PIN = 11;
int RELAY1 = 6;
int RELAY2 = 7;
int RELAY3 = 8;
int RELAY4 = 9;
int LED = 13;
int DATA;
byte serialA;

//Initialize LCD
LiquidCrystal lcd(12,10,5,4,3,2);

//Initialize IR Reciever
IRrecv irrecv(RECV_PIN);
decode_results results;

//Function to decode Remote Data using IR
void dump(decode_results *results) {
  int count = results->rawlen;
  if (results->decode_type == UNKNOWN) {
    Serial.println("Could not decode message");
  } 
  else {
    if (results->decode_type == NEC) {
      Serial.print("Decoded NEC: ");
    } 
    else if (results->decode_type == SONY) {
      Serial.print("Decoded SONY: ");
    } 
    else if (results->decode_type == RC5) {
      Serial.print("Decoded RC5: ");
    } 
    else if (results->decode_type == RC6) {
      Serial.print("Decoded RC6: ");
    }
    DATA=results->value;
    Serial.print(DATA, DEC);
    Serial.print(" ");
 
  }
   if(DATA==7136)          //1
   {
     lcd.clear();
     lcd.print("LIGHT ON");
     digitalWrite(RELAY1,HIGH);
   } 
   else if(DATA==7120)     //2
   { 
     lcd.clear();
     lcd.print("FAN ON");
     digitalWrite(RELAY2,HIGH);
   } 
   else if (DATA==7152)    //3
   { 
     lcd.clear();
     lcd.print("LIGHT BLINK");
    
     digitalWrite(LED,HIGH);
     delay(2000);
     digitalWrite(LED,LOW);
     
   } 
   else if (DATA==7112)    //4
   { 
     lcd.clear();
     lcd.print("NO DEVICE");
     digitalWrite(RELAY4,HIGH);
   } 
   else if(DATA==7144)      //5
   {  
     lcd.clear();
     lcd.print("LIGHT OFF");
     
     digitalWrite(RELAY1,LOW);
   }
   else if (DATA==7128)     //6
   { 
     lcd.clear();
     lcd.print("FAN OFF");
     digitalWrite(RELAY2,LOW);
   } 
   else if(DATA==7160)     //7
   {  
     lcd.clear();
     lcd.print("BLINKING OFF");
     digitalWrite(LED,LOW);
     delay(2000);
     digitalWrite(LED,LOW);
   } 
   else if(DATA==7108)    //8
   {  
     lcd.clear();
     lcd.print("NO DEVICE");
     digitalWrite(RELAY4,LOW);
   } 
   else if(DATA==7140)     //9
   { 
    lcd.clear(); 
     lcd.print("NO DEVICE");
     digitalWrite(13,HIGH);
   } 
   else if(DATA==7130)     //OK
   {
     lcd.clear();
      lcd.print("ALL DEVICES ON");
      digitalWrite(RELAY1,HIGH);
      digitalWrite(RELAY2,HIGH);
      digitalWrite(RELAY3,HIGH);
      digitalWrite(RELAY4,HIGH);
      digitalWrite(LED,HIGH);
   }
    
   else if(DATA==7122)     //OFF RED
   {
     lcd.clear();
      lcd.print("DEVICES OFF");
      digitalWrite(RELAY1,LOW);
      digitalWrite(RELAY2,LOW);
      digitalWrite(RELAY3,LOW);
      digitalWrite(RELAY4,LOW);
      digitalWrite(LED,LOW);
   }
}

void Recieve_BT_Data(byte serialA)
{
  switch(serialA)
  {
    case 1: 
    	lcd.clear();
    	lcd.print("LIGHT ON");
    	digitalWrite(RELAY1,HIGH);
    	delay(1000);
    break;
    case 2: 
    	lcd.clear();
    	lcd.print("LIGHT OFF");
    	digitalWrite(RELAY1,LOW);
    	delay(1000);
    break;
    case 3: 
    	lcd.clear();
    	lcd.print("LIGHT BLINK");
    	digitalWrite(LED,HIGH);
    	delay(2000);
        digitalWrite(LED,LOW);
    break;
    case 4: 
    	lcd.clear();
    	lcd.print("FAN ON");
    	digitalWrite(RELAY2,HIGH);
    	delay(1000);
    break;
    case 5: 
    	lcd.clear();
    	lcd.print("FAN OFF");
    	digitalWrite(RELAY2,LOW);
    	delay(1000);
     break;
    default:
     break;
  
}
}
void setup()
{
  pinMode(RELAY1, OUTPUT);
  pinMode(RELAY2, OUTPUT);
  pinMode(RELAY3, OUTPUT);
  pinMode(RELAY4, OUTPUT);
  pinMode(LED, OUTPUT);
  Serial.begin(9600);		//Start the Serial Communication with 9600 Baud Rate
  irrecv.enableIRIn(); 		// Start the receiver
   lcd.begin(16, 2);
   lcd.clear();
   lcd.print("   SMART HOME");
   
}

unsigned long last = millis();

void loop() {
  if (irrecv.decode(&results)) {
    if (millis() - last > 250) {
      digitalWrite(LED,HIGH);
      dump(&results);
    }
    last = millis();      
    irrecv.resume(); 		// Receive the next value
  }
  
  if(Serial.available()>0)
  {
    serialA= Serial.read();
    //Serial.println(serialA);
    Recieve_BT_Data(serialA);
  }
}

LEARN HOW TO MAKE A ANDRIOD APP TO CONTROL APPLIANCES CONNECTED WITH BLUETOOTH