Arduino-Remote Control Home Automation
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. Our article on Switchboard for Home Automation will give you a clear idea on the subject.
Other articles on Home Automation have also been published. You may also refer them and try it out.
Refer : Home Automation Using Arduino & GSM Module Bluetooth Home Automation Using AVR & Android App
An Arduino Nano is used in the project, because its size is small and does not require any external programmer. If you are a pro in Arduino, you can use any other Arduino according to your choice. Arduino control the relays according to the button pressed on the remote. A 3-pin sensor TSOP 1838T is connected to the Arduino, which reads the signal and sends to the Arduino. Arduino decodes the signal and turn ON and OFF the appliances accordingly.
The project is not very easy but you can make easily, because PCB designed on EAGLE, so you just need to print the PCB.
IR Remote Control Home Automation – Components Used
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.
In the project, a12-volt relay used for switching the home appliances. It can hold 7Amps of current. A transistor is using for switching the relay and a diode is connected parallel to the relay but in reverse bias, which is used for limiting the reverse current.
You may find this helpful - Working of Relays
Arduino can operate the low current components like LED and Buzzer, but relays need high current (100 mA to 250mA) to switch appliances. Thus, a transistor is used for switching the relays. Transistor’s emitter pin is connected to GND and collector pin is connected to coil pin of relay, Arduino gives signal through a resistance to Base pin of transistor. When logical HIGH given to the base pin of Arduino collector and emitter are short circuits, so current passed through the coil of relay. Now coil energized and the relay switched ON.
In the circuit sensor’s output pin connected to D12 pin of the Arduino, remaining pins of sensor connected to Vcc and GND.
A2, A3, A4 and A5 pins of the Arduino connected to the transistor’s base pins through 10K ohm Resistance. Emitter pin connected to the GND and collector pin connected to the coil pin of the relay. Relay’s other pin is connected to the 12 volt.
Appliances are connected to the mains through relay’s C (Common) and NO (Normally Open) pin of the relay.
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 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.
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.
Two codes are used in this project, first is used for reading the value of Switch code and second is the main code.
Program to read the value of Switch Code - Download
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.
Main Code - Download
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.