bluetooth based 8051 home automation




In this project we have used 8051 microcontroller for controlling the whole process of this project. And a Bluetooth module is used for controlling the home appliances wirelessly. Home appliances will turned ON and OFF when user will touch button in the Bluetooth mobile app in Android mobile phone. To run this project, first we need to download Bluetooth app form Google play store. We can use any Bluetooth app that can send data using Bluetooth. Here are some apps name that can be used:
  1. Bluetooth Spp pro
  2. Bluetooth controller
  3. After installing the App, you need to open it and then search Bluetooth device and select HC-05 Bluetooth device. And then configure keys.
    Here in this project we have used Arduino Bluetooth controller app.
    1. Download and install Bluetooth Controller.
    2. Turned ON mobile Bluetooth.
    3. Now open Bluetooth controller app
    4. Press scan
    5. Select desired Bluetooth device (Bluetooth Module HC-05).
    6. Now set keys by pressing set buttons on screen

Now, when we touch any button in Bluetooth controller app then Android phone sends a value to Bluetooth module, after receiving this value, Bluetooth module sends the received value to the microcontroller and then microcontroller reads it and compare it with predefined value. If any match is occurred then microcontroller performs relative operation. Same operation will performed each time when button pressed.
Bluetooth Controlled Home Automation Block diagram
Now, when user touch ‘Fan On’ button in Bluetooth controller app then microcontroller receives ‘1’ via Bluetooth module and then controller Switch ‘On’ the Fan by using relay driver and relay. And when user touch ‘Fan Off’ button in Bluetooth controller app then microcontroller receives ‘2’ via Bluetooth module and then controller Switch ‘Off’ the Fan by using relay driver and relay.
Likewise 3,4,5,6 numbers are sent by Android Phone, when Light On, Light Off, TV On, TV Off button has been touched respectively:
Button
Data
Operation
Fan On
1
Fan Turned On
Fan Off
2
Fan Turned Off
Light On
3
Light Turned On
Light Off
4
Light Turned Off
TV On
5
TV Turned On
TV Off
6
TV Turned Off

Circuit Diagram and Explanation

Circuit connections of this project are very simple. Bluetooth module’s Rx and Tx pins are directly connected to the  Tx and Rx pins of Microcontroller. Three 5 volt relays are used as a switch for turning On and Off the home appliances running on AC mains. And a relay driver ULN2003 is used for driving relays. Fan, Light and TV are connected at P2.1, P2.2 and P2.3 via relays and relay driver. An 11.0592 MHz Crystal oscillator is used in this circuit for generating clock signal for microcontroller. And a 5 volt voltage regulator LM7805 is used for provide 5 volt for the whole circuit.
 Bluetooth Controlled Home Automation System Circuit Diagram

Code: 
#include<reg51.h>
sbit Fan=P2^0;
sbit Light=P2^1;
sbit TV=P2^2;
 char str;
 char Charin=0;
void delay(int time)
{
 unsigned int i,j;
 for(i=0;i<time;i++)
 for(j=0;j<1275;j++);
}
void Serialwrite(char byte)
{
  SBUF=byte;
  while(!TI);
  TI=0;
}
void Serialprintln(char *p)
{
  while(*p)
  {
    Serialwrite(*p);
    p++;
  }
  Serialwrite(0x0d);
}
void Serialbegin()
{
   TMOD=0x20;
   SCON=0x50;
   TH1=0xfd;
   TR1=1;
}
void main()
{
  P2=0x00;
  Serialbegin();
  Serialprintln("System Ready...");
  delay(50);
  while(1)
  {
    while(!RI);
    Charin=SBUF;
    str=Charin;
    RI=0;
      if(str=='1')
      {
        Fan=1;
        Serialprintln(" Fan ON");
        delay(50);
      }
      else if(str=='2')
      {
        Fan=0;
        Serialprintln(" Fan OFF");
        delay(50);
      }
       else if(str=='3')
      {
        Light=1;
        Serialprintln(" Light ON");
        delay(50);
      }
       else if(str=='4')
      {
        Light=0;
        Serialprintln(" Light OFF");
        delay(50);
      }
       else if(str=='5')
      {
        TV=1;
        Serialprintln(" TV ON");
        delay(50);
      }
       else if(str=='6')
      {
        TV=0;
        Serialprintln(" TV OFF");
        delay(50);
      }
      str=0;
  }
}
Android based bluetooth home automation Vedio: https://www.youtube.com/edit?o=U&video_id=a9-WUR632bw

you can watch my vedio on youtube about hardware also:https://www.youtube.com/watch?v=a9-WUR632bw

Comments

  1. Please give me the code bcoz this code shows me error unlimited in keil plz give me the correct cide

    ReplyDelete
    Replies
    1. this code is perfectly fine its is #c code maybe you are doing something wrong while creating it

      Delete
  2. Which software are you used for coding?

    ReplyDelete

Post a Comment