Arduino projectsHome Automation

TV Remote controlled Home Automation

Have you ever wondered that how it would be to control you home appliances using your TV/DVD or any IR Remote?

Then, this project will provide you the easy to follow tutorial on making your imagination a reality.

Here, you will learn to automate your home appliances by using any kind of IR Remote. The knowledge gained in this project will benefit you in projects related to the use of universal IR Receiver with Arduino and further you will be able to make any automation projects related to industries, Home, School or office.

Project Level: Intermediate

Prerequisite Required: Basics of Arduino, HC-05, Relay and Decoding signal from remote

Warning:

 This project involve interfacing HIGH VOLTAGE supply, so check connection 
twice and seek the help from elder or someone, who have better knowledge of
 handling High Voltage supply.

So, let’s get started!

Components Required:

  • Arduino Uno/Nano/Mega (Amazon/Ebay/Flipkart/AliExpress)
  • Relay Module                 (Amazon/Ebay/Flipkart/AliExpress)
  • Jumper Wires                 (Amazon/Ebay/Flipkart/AliExpress)
  • Universal IR Receiver      (Amazon/Ebay/Flipkart/AliExpress)
  • Connecting wire/Switch Board

*Please note: These are affiliate links. I may make a commission if you buy the
components through these links.
I would appreciate your support in this way to help
this website!

1. Decoding Remote: Reading the button’s value:

Since, Arduino IDE comes with a remote library that will not work with this project, so you need to include this library (Click) in your Arduino IDE. And delete the library in the Arduino IDE previously i.e. having name similar to ”REMOTE.h”.

 Connection :

Code for Decoding:

#include <IRremote.h>

int IRpin = 12;
IRrecv irrecv(IRpin);
decode_results results;


void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}  
void loop() 

{   
  if (irrecv.decode(&results)) 
    {
     Serial.println(results.value); // Print the Serial 'results.value'
      delay(10);

     irrecv.resume();   // Receive the next value
    }
}

 

After uploading the above code, open the Serial Monitor and with ever press of the button you will find some code reflected on the serial monitor. Note down these codes corresponding to each button you want to use. Here, leave the codes that repeats whenever any button is pressed, since it is of no use.

Once, you have got the button hex-code decoded. You are now ready to control the relays with that remote.

Building Automation System :

Connection:

Code for Home Automation:

//  This is written by Alok Shaw, author of www.roboshala.com. Anyone one is free to use and modify the code. 
//  Before running this code make sure to copy the IRremote folder to your Arduino Librabries
//  and also delete any previous library on IR remote
//  Visit : www.roboshala.com for more info.

#include <IRremote.h>

int IRpin = 12;
IRrecv irrecv(IRpin);
decode_results results;
int Relay1=7;               // Initializing the pins for Relay
int Relay2=8;
int Relay3=9;
int Relay4=10;
int val1=0;                 // Inializing the variable for storing the last status of Relay_pins
int val2=0;
int val3=0;
int val4=0;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(Relay1,OUTPUT);
  pinMode(Relay2,OUTPUT);
  pinMode(Relay3,OUTPUT);
  pinMode(Relay4,OUTPUT);
  digitalWrite(Relay1,HIGH);
  digitalWrite(Relay2,HIGH);
  digitalWrite(Relay3,HIGH);
  digitalWrite(Relay4,HIGH);
}  
void loop() 

{   
  if (irrecv.decode(&results)) 
    {
     Serial.println(results.value); // Print the Serial 'results.value'
      delay(10);

     irrecv.resume();   // Receive the next value
    }

    
    if(results.value==1086300255)
    {
      val1=digitalRead(Relay1);
      if(val1==0)
      {
        digitalWrite(Relay1,HIGH);
        val1=1;
        delay(100);
      }
      else
      {
      digitalWrite(Relay1,LOW);
      val1=0;
      delay(100);
      }
    }

    
     if(results.value==1086259965)
    {
      val1=digitalRead(Relay2);
      if(val2==0)
      {
        digitalWrite(Relay2,HIGH);
        val2=1;
        delay(100);
      }
       else
      {
      digitalWrite(Relay2,LOW);
      val2=0;
      delay(100);
      }
    }

    
     if(results.value==1086320655)
    {
      val1=digitalRead(Relay3);
      if(val3==0)
      {
        digitalWrite(Relay3,HIGH);
        val3=1;
        delay(100);
      }
       else
      {
      digitalWrite(Relay3,LOW);
      val3=0;
      delay(100);
      }
    }

    
     if(results.value==1086268125)
    {
      val4=digitalRead(Relay4);
      if(val4==0)
      {
        digitalWrite(Relay4,HIGH);
        val4=1;
        delay(100);
      }
       else
      {
      digitalWrite(Relay4,LOW);
      val4=0;
       delay(100);
      }
    }
    
}

 

Checkout other tutorials on Home Automation :

IOT Home Automation over Internet using Blynk

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Close