Home automation using TV Remote

Updated: Apr 5

Home automation using TV remote is a simple DIY project in which a remote is used to control the electronic appliances in home or office. In this project we use a remote control (to simply ON and OFF) various electronic devices, thus acheiving a central home automation system. It is a concept where a single device is used to operate many aspects that we encounter in our daily routine like switching on and off different devices, temperature monitoring, fire alarms etc., Now a days remote controls has been a part of our daily routine but the remotes that we encocunter regularly in our home are specific i.e., the remote is specific in controlling a particular device. But, in this project we control various appliances with a single remote control.


Hardware Requirements:


1. Arduino UNO: The Arduino is a programmable #microcontroller, it's an open-source electronics proto-type platform. It interacts with the user by receiving input with the aid of sensors and provides the output employing LED, buzzer, etc.,


Arduino UNO

In order to know more about the Arduino UNO, go through this article.

You can purchase Arduino UNO here.


2. VS838 IR Sensor: An infrared sensor is an electronic device, that emits IR radiation in order to sense some aspects of the surroundings. An IR sensor can measure the heat of an object as well as detects the movement. In this project we will be using VS838 IR sensor.


You can purchase VS838 sensor here.


2 channel relay module: In this project we aim to control ac powereddevices like fans and lamps. Since the output of the Arduino UNO is only 5V, we cannot directly control these devices. We can do this acivity by using a relay module. A relay module is a device which requires little amount of current to switch ON and can control larger current devices.


2 Relay Module

You can purchase 2 channel relay module here.


4. Jumping Wires: Jumper wires are used to establish connections between different components in the circuit.


Jumping wires

You can purchase Jumping wires here.


Software Requirements:


Arduino IDE:

Arduino IDE logo

The Arduino Integrated Development Environment (IDE) is a cross-platform application (for Windows, macOS, Linux) that is written in functions from C and C++. It is used to write and upload programs to Arduino compatible boards, but also, with the help of third-party cores, other vendor development boards.


Circuit connection:

Circuit connection involves the following steps:

  • The left most pin(signal pin) of the IR receiver is connected to the digital pin number 11 of the Arduino.

  • Ground of the IR receiver is connected to the ground of the arduino.

  • The 5V supply of the IR sensor is connected to the Vin pin of the Arduino.

  • The ground of the 2 channel relay module is connected to the ground of the Arduino, Vcc is connected to the 5V of the Arduino.

  • IN1 and IN2 are the two pins which control the two relay modules and these pins are connecte to the digital pin numbers 9 and 8 of the Arduino respectively.

  • Each channel has a closed pin, common pin and an open pin. The common pin is connected to one terminal of the ac bulb and the other terminal will be connected to one terminal of the power supply. Open pin of the relay is connected directly to neutral of the power supply.

  • In the same way the other AC bulb is also connected.

Code Explanation:

The code is simple and easy to understand.

#include <IRremote.h>

Before getting started with the coding part, we first need to include the IRremote library for that you need to go to sketch -> include library -> Manage libraries and you will get a pop up of library manager, in the search bar search for IRremote and install irremote by sheriff to include the library.

int RECV_PIN = 11; //pin at which the OUT pin of IR receiver is connected

Pin 11 receives the data from the IR receiver.

const int codeRelay1 = 16732080; //replace your code here for relay1
const int codeRelay2 = 16764720; //replace your code here for relay2

Each button will have a unique code for its operation.

int relay1 = 9; //pin at which relay1 is connected
int relay2 = 8; //pin at which relay2 is connected

In this part of the code, Pin number 9 is assigned to the relay1 and pin number 8 is assigned to the relay2 respectively.

IRrecv irrecv(RECV_PIN);
decode_results results;

These are the functions from the IRremote library.

void setup()
{
  Serial.begin(9600);
  // In case the interrupt driver crashes on setup, give a clue
  // to the user what's going on.
  Serial.println("Enabling IRin");
  irrecv.enableIRIn(); // Start the receiver
  Serial.println("Enabled IRin");
  pinMode(relay1, OUTPUT); digitalWrite(relay1, LOW);
  pinMode(relay2, OUTPUT); digitalWrite(relay2, LOW);
}

void setup is a function and in this, we initiated the serial communication at the baud rate of 9600. We are starting the receiver and assigning the pins of relay1 and relay2 as output pins and set them low.

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);
    code = results.value, DEC;
    irrecv.resume(); // Receive the next value
  }

Here we are checking for the input from the IR receiver. And we are storing the value into a variable called code.

if (code == codeRelay1)
  {
    if (digitalRead(relay1) == HIGH)
     { digitalWrite(relay1, LOW);
      Serial.println("Tube Lights OFF"); }
    else
     { digitalWrite(relay1, HIGH);
      Serial.println("Tube Lights ON");  }
 
    code = 0;
  }

If the value in the code matches with the above mentioned value, then the light is ON if we press the same button again he light will turn OFF. The same logic works for the relay 2 as well.

Complete Code:

#include <IRremote.h>
 
int RECV_PIN = 11; //pin at which the OUT pin of IR receiver is connected
 
const int codeRelay1 = 16732080; //replace your code here for relay1
const int codeRelay2 = 16764720; //replace your code here for relay2
 
int code;
 
int relay1 = 9; //pin at which relay1 is connected
int relay2 = 8; //pin at which relay2 is connected
 
 
IRrecv irrecv(RECV_PIN);
 
decode_results results;
 
void setup()
{
  Serial.begin(9600);
  // In case the interrupt driver crashes on setup, give a clue
  // to the user what's going on.
  Serial.println("Enabling IRin");
  irrecv.enableIRIn(); // Start the receiver
  Serial.println("Enabled IRin");
  pinMode(relay1, OUTPUT); digitalWrite(relay1, LOW);
  pinMode(relay2, OUTPUT); digitalWrite(relay2, LOW);
}
 
void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);
    code = results.value, DEC;
    irrecv.resume(); // Receive the next value
  }
 
  if (code == codeRelay1)
  {
    if (digitalRead(relay1) == HIGH)
     { digitalWrite(relay1, LOW);
      Serial.println("Tube Lights OFF"); }
    else
     { digitalWrite(relay1, HIGH);
      Serial.println("Tube Lights ON");  }
 
    code = 0;
  }
  else if (code == codeRelay2)
  {
    if (digitalRead(relay2) == HIGH)
     { digitalWrite(relay2, LOW);
      Serial.println("Bulb OFF"); }
    else
     { digitalWrite(relay2, HIGH);
      Serial.println("Bulb ON"); }
    code = 0;
  }
 
  //delay(100);

}
Home_automation_using_IR
.txt
Download TXT • 2KB

Download the entire code here.


Working:

First we connect Arduino to the PC and upload the code. After done with uploading the code, goto tools and serial monitor. Now if you press a button on the TV remote let's say a volume up button, you will see there is a code appearing on the serial monitor and that code is specific for that button. Now, if you press any other button you will be able to see a different number on the serial monitor window which is unique. Now in this project we are controlling two led's. For which initially you uploaad the code and open serial monitor. If we press minus button one of the led's would glow and if we press button then the other switch will also be turned ON. If we press the same button for the second time, then the bulb will be switched OFF.


Watch the video attached below for a clear understanding of how the connections are made and the simulation procedure.


Watch the video attached below for a clear understanding of how the connections are made and the simulation procedure.


Video By - Farhan Ahamed



See Also:

Interfacing a DC motor with Arduino using TinkerCAD

IoT Smart Bulb using NodeMCu and Blynk App

Controlling LEDs using IR Remote and Arduino UNO on TinkerCAD


  • Facebook
  • YouTube
  • Instagram
  • LinkedIn
LearnElectronics
Contact Us