Ticker

6/recent/ticker-posts

Home Automation System

Home Automation System Using Smartphone

How to Build a Bluetooth controlled Home Automation Setup Using Arduino

 

Would you like to computerize your home? Ever wished to control your machines with a swipe on your telephone? Or then again would you like to figure out how to construct robotization gadget for yourself? 

In this instructional exercise, we'll investigate how you can control a light, fan or some other electrical machine in your space utilizing an Arduino. Toward the finish of the venture, you will have the option to control the associated load from your cell phone.

Quick Economics:

The entire arrangement takes under 15 minutes to design and would cost under $30. In addition, the steady expense of adding electrical apparatus boils down to just $1.5/gadget, which is very moderate for experimentation.

 

Required Material:
In order to get started, you’ll need the following components:

Hardware :






 

 4 Channel Relay

 

 1

 

 HC-05 Wireless Bluetooth module

 

 1

 

 bulb

 

 1

 

 Arduino Uno

 

 1

 

 Jumper wires(generic)

 

 

 Android Phone

 

 

SOFTWARE USED :

  • Arduino Bluetooth Controller (android)

  • Arduino IDE.

CIRCUIT DIAGRAM




How to Connect Bluetooth HC-05 and Relay Module to Arduino

  1. Connect Vin and GND pin of Arduino to 5v and ground to hc-05 module
  2. Connect the TXD pin on the HC-05 module with the RXD pin (Pin 0) of Arduino.
  3. TXD on HC-05: Transmit data from the Bluetooth transceiver.
  4. Pin 0 on Arduino (RXD): Receive data on Arduino two-way by connecting these pins, we are establishing a two-way communication between Arduino and HC-05, so that we can turn the device get on/off with the command properly.
  5. connect VOC and ground of relay module to 5v and ground of arduino uno.
  6. connect IN1 of relay module to pin2 of arduino uno.(you can connect IN2,IN3,IN4,etc.., to pin 3,4,5...).
  7. connect C(common) of relay module to main supply and connect NO(normally open) of relay to one side of bulb and the other side of bulb goes to neutal.

Bluetooth Test: Checkpoint

Quick Test:

Whenever you have associated the HC-05 module with the Arduino, you can control the Arduino from 5v inventory or USB link. In the event that the red and blue LEDs on HC-05 are squinting, you have effectively matched the Bluetooth module with Arduino. 

You can likewise check the Bluetooth network status utilizing the State pin to Arduino.

 

Setting up the Relay Circuit

Whenever you have designed the arrangement on Arduino, the subsequent stage is to associate the load with our relay module for example the light (for our situation). Here's a straightforward circuit that discloses how you need to wire the connection:

How about we make a stride back and comprehend what we're doing here. As appeared in the above graph, the relay module functions as an electronic switch. We are interfacing this in arrangement so we can open and associate the circuit from the micro-controller module.

Here's the manner by which you can wire up the relay module with Arduino: 

Initially, interface the 5V and GND pins to the transport terminals on the breadboard.

Interface the IN1 pin to the relay board with PIN 2 of Arduino. 

In the event that you have a multi-channel module (2, 4 or 8 channels), you can associate IN2, IN3 … IN(n) with various computerized pins of Arduino, and rehash the underneath ventures for designing different pins.

Subsequent to interfacing the signal pins to Arduino, we need to associate the AC load to the transfer module. Presently, on the off chance that you take a gander at the terminal block on the relay module, you would discover three slots.

We should comprehend what these slots truly mean:

C
Common
NC
Normally Connected
NO
Normally Open

 

COM – Common Terminal:

It is the middle terminal, Power to the load is associated with this terminal.

NO -Normally open:

It acts like a switch. Since it remains regularly open, there will be no contact among COM and NO, When we trigger the relay module, it associates with COM by the electromagnet inside the hand-off and load gets the inventory, which forces up the light. Thus the circuit is shut until we trigger the state to low in the relay.

NC-Normally Closed:

It is consistently in contact with COM when the relay isn't powered. When the relay is triggered it opens the circuit. 

In the consistent state (when the relay is off), the COM port is associated with NC (Normally Connected) port, which implies in the event that you interface the bulb on the NC terminal, it will remain ON in any event, when the relay will be OFF, as the circuit is as of now finished (That's the reason it's designated "ordinarily associated"). 

For our utilization case, we need to turn on the bulb just when we impart a sign from a smartphone. That's the explanation we associate the load on the NO (Normally Open) terminal, so when the relay is triggered from the Arduino, the contact brush flicks from NC to NO terminal, accordingly finishing the circuit.


Code :


String inputs;
#define relay1 2 //Connect relay1 to pin 9
#define relay2 3 //Connect relay2 to pin 8
#define relay3 4 //Connect relay3 to pin 7
#define relay4 5 //Connect relay4 to pin 6
#define relay5 6 //Connect relay5 to pin 5
#define relay6 7 //Connect relay6 to pin 4
#define relay7 8 //Connect relay7 to pin 3
#define relay8 9 //Connect relay8 to pin 2
void setup()
{
Serial.begin(9600); //Set rate for communicating with phone
pinMode(relay1, OUTPUT); //Set relay1 as an output
pinMode(relay2, OUTPUT); //Set relay2 as an output
pinMode(relay3, OUTPUT); //Set relay1 as an output
pinMode(relay4, OUTPUT); //Set relay2 as an output
pinMode(relay5, OUTPUT); //Set relay1 as an output
pinMode(relay6, OUTPUT); //Set relay2 as an output
pinMode(relay7, OUTPUT); //Set relay1 as an output
pinMode(relay8, OUTPUT); //Set relay2 as an output
digitalWrite(relay1, LOW); //Switch relay1 off
digitalWrite(relay2, LOW); //Swtich relay2 off
digitalWrite(relay3, LOW); //Switch relay1 off
digitalWrite(relay4, LOW); //Swtich relay2 off
digitalWrite(relay5, LOW); //Switch relay1 off
digitalWrite(relay6, LOW); //Swtich relay2 off
digitalWrite(relay7, LOW); //Switch relay1 off
digitalWrite(relay8, LOW); //Swtich relay2 off
}
void loop()
{
while(Serial.available()) //Check if there are available bytes to read
{
delay(10); //Delay to make it stable
char c = Serial.read(); //Conduct a serial read
if (c == '#'){
break; //Stop the loop once # is detected after a word
}
inputs += c; //Means inputs = inputs + c
}
if (inputs.length() >0)
{
Serial.println(inputs);

if(inputs == "A")
{
digitalWrite(relay1, LOW);
}
else if(inputs == "a")
{
digitalWrite(relay1, HIGH);
}
else if(inputs == "B")
{
digitalWrite(relay2, LOW);
}
else if(inputs == "b")
{
digitalWrite(relay2, HIGH);
}
else if(inputs == "C")
{
digitalWrite(relay3, LOW);
}
else if(inputs == "c")
{
digitalWrite(relay3, HIGH);
}
else if(inputs == "D")
{
digitalWrite(relay4, LOW);
}
else if(inputs == "d")
{
digitalWrite(relay4, HIGH);
}
else if(inputs == "E")
{
digitalWrite(relay5, LOW);
}
else if(inputs == "e")
{
digitalWrite(relay5, HIGH);
}
else if(inputs == "F")
{
digitalWrite(relay6, LOW);
}
else if(inputs == "f")
{
digitalWrite(relay6, HIGH);
}
else if(inputs == "G")
{
digitalWrite(relay7, LOW);
}
else if(inputs == "g")
{
digitalWrite(relay7, HIGH);
}
else if(inputs == "H")
{
digitalWrite(relay8, LOW);
}
else if(inputs == "h")
{
digitalWrite(relay8, HIGH);
}
inputs="";
}
}

Post a Comment

0 Comments