In this project, we are going to show you how to control home appliances using a TV Remote. This same principle can be applicable in offices and industries as well.

The project deals with the automation of four home appliances, like Tube lights, fan, bulbs, and of course TV. To automate them, four relays must be used. The circuit provided below is designed to switch the relays. But to automate and control home appliances, you must have a basic idea of connecting them to switchboards, and must learn on what to do if the remote malfunctions

IR Remote Control Home Automation – Components Used

Component Specification Quantity
Arduino          Nano 1
DC Adapter    12 Volt 1
IR Sensor   TSOP 1838T 1
Relay           12 Volt 4
Transistor     BC547 4
Resistance      10K 4
Resistance     330 Ohms 4
LED Red         4
Indicator Light 240 Volts 4

Working

In the project, an Arduino is using as controlling unit. A TSOP 1838T sensor is using for receiving signal from the remote. Output pin of sensor is connected to the Arduino, when any button of the remote is pressed, IR LED of remote sends a unique encoded signal, this signal is received by sensor and sent to the Arduino, The Arduino decode the signal and turn on and off the lights according to the signal. 12-volt relays are used for switching the appliances.

This is an IR sensor, which receives the signal of IR Remote. This sensor have three pins 1st is Vcc 2nd is GND and third is OUT; the operating voltage of the sensor is 3.7 to 5 volt.

Circuit Diagram




Attach The Library


Before uploading the code, attach the library of IR Remote to Arduino, for this follow these steps
Download the library here.
Extract the ZIP file
Copy the inside folder and paste into the libraries folder.
Close the Arduino IDE and Reopen.
Check the new library on example.

Remote Code


Remote sends the unique encoded signal, so first we need to identify the code according to the switch so follow these steps.
Make a circuit as shown in the circuit diagram.
Upload the Code1 to the Arduino.
Open the serial Monitor.
Set the Baud Rate 9600.
Press the buttons of remote and note down the values of serial monitor.
Double check the values and ignore the “FFFFFFFF” Code.

Now we have codes of all the buttons, so we can program the Arduino for home appliances.

Programming


We have all the Switch Codes, for uploading the main code follow these steps.
Open the Code2
Select any four buttons to operate the appliances.
Go line 42 of Code2.
Copy any code value of a switch and paste instant of YYYYYYY
Do this for lines 43, 44 and 45, and chooses the different switch code.
Code

Two codes are used in this project, first is used for reading the value of Switch code and second is the main code.

Code1:

#include <IRremote.h>

IRrecv irrecv(12);
decode_results results;

void setup(){
  Serial.begin(9600);
  irrecv.enableIRIn();
}

void loop(){
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); 
    }
}




In the code1 first header file of IR Remote (IRremote.h) is declared. In the next line a function “IRrecv irrecv(12)” is used for declaring the pin of Arduino, which is connected to IR sensor. After it a function “decode_result results” is used for decoding the switch code.

In the “void setup” “serial.begin(9600)” is used for enabling the serial Monitor. After it, “irrecv.enableIRIn” used for enabling the IR Sensor.

In the void loop an “if Condition” is used, it become true when any button of the remote is pressed. After it, HEX value of result printed on serial monitor. After all “irrecv.resume()” resumes the IR Sensor


Code2 :


#include <IRremote.h>

IRrecv irrecv(12);
decode_results results;

int lig1 = A2;
int lig2 = A3;
int lig3 = A4;
int lig4 = A5;

int flag1 = 0;
int flag2 = 0;
int flag3 = 0;
int flag4 = 0;

unsigned int value; 

void setup() {
  irrecv.enableIRIn();
  
  pinMode(lig1, OUTPUT);
  pinMode(lig2, OUTPUT);
  pinMode(lig3, OUTPUT);
  pinMode(lig4, OUTPUT);
  
  pinMode(13, OUTPUT);
}

void loop() {
  if (irrecv.decode(&results)) { 
    value = results.value;
    irrecv.resume();

    digitalWrite(13, HIGH);
    delay(100);
    digitalWrite(13, LOW);
    
    if (results.value == 0x1FE50AF) {flag1 = !flag1; digitalWrite(lig1, flag1 ? HIGH : LOW); value =0; }
    if (results.value == 0x1FED827) {flag2 = !flag2; digitalWrite(lig2, flag2 ? HIGH : LOW); value =0; }
    if (results.value == 0x1FEF807) {flag3 = !flag3; digitalWrite(lig3, flag3 ? HIGH : LOW); value =0; }
    if (results.value == 0x1FE30CF) {flag4 = !flag4; digitalWrite(lig4, flag4 ? HIGH : LOW); value =0; }    
    }
}


Many functions of Code2 are similar to code, so we will not discuss the same function

From the line 6 to line 9 four integers are declared by name lig1, lig2, lig3 and lig4 they are used for indicating the pins.

After it, four integers are declared by name flag1, flag2, flag3 and flag4; all the flags are used for storing the status of output pin. After it, an unsigned integer declared by name value.

In the “void setup()”, first IR sensor is enabled. After it all the pins lig1, lig2, lig3, lig4 and D13 declared as output.

In the void loop an “if condition” is used, it become true when any switch is pressed, now decoded value is saved in an integer “value”. After it, IR sensor resumed. In line 34, 35 and 36 on board led are switched on for 100 milliseconds.

In the line 38 “if condition” is used for comparing the saved value and value coming from remote. When it becomes true, flag1 is reversed (‘0’to ’1’ and ‘1’ to ‘0’) and corresponding pin of Arduino switched ON and switched OFF. After it, value becomes zero. This same approach used in lines 39, 40 and 41 for switching other pins.


No comments

Theme images by Dizzo. Powered by Blogger.