Project tutorial

IR Home Automation on Arduino © GPL3+

Control all the appliances (up to 8) using just a single IR Remote.

  • 622 views
  • 0 comments
  • 9 respects

Components and supplies

Apps and online services

About this project

Everyone wants a remote to control all the appliances in your home. Some companies are introducing wireless controllers for various appliances but they are costly and you have to upgrade the existing for additional cost. So, what about making your own home automation system to control the appliances up to 8.

The Working

High Voltage VS Low Voltage

We all know that the appliances work on 110 V (USA) and 220 V (Asia) depending upon the region. But, the Arduino we are using is working on just 5 V. If we connect it directly to the mains supply to control the appliances just like controlling the LEDs, the board or the microcontroller will get burned. So, we use 5 V relay which works as an interface between the two voltage supplies. A signal is sent to relay by Arduino and relay switches on the circuit of the appliance.

Wireless Transmission of Data

We know that how will we switch the supply on but we need to send the signal from an IR remote to the receiver with Arduino. So, we can use any generic IR remote controller available in market. But, every remote controller comes with different codes for their buttons which they send it through IR LED. So, we need to find those codes for a random IR remote controller we are using.

For that, please click here for another project of mine on Hackster.io.

Hook-up the Circuit

LCD connections: For the LCD connections, please click here.

IR receiver and relay connections:

Connect –

  • First pin of IR receiver to GND.
  • Second pin of IR receiver to +5 V.
  • Third pin of IR receiver to PIN12 of Arduino.
  • VCC of both the relays with to +5 V in Arduino.
  • GND of both the relays with to GND in Arduino.
  • SIG or INPUT of relay 1 with PIN2 in Arduino.
  • SIG or INPUT of relay 2 with PIN3 in Arduino.

Testing it up!

Remember to install the IRremote.h library in the Arduino IDE.

  • Upload the code attached in the end of project.
  • Wait for the system to initialise.
  • Now, press the POWER button to switch ON/OFF all the appliances.
  • Press each corresponding button (like 1 for fan, 2 for light and so on) to switch ON/OFF them.

Try this and let me know in the comment section of your face any problem in the project I have published.

Respect for appreciating me for making more projects!

Schematics

Schematics for the project
Home automation schematics bb xwjlj421ng
Simulator on 123 Circuits

Code

CodeC/C++
/*******************************************************************************     Program can be used to find the IR codes of different IR remotes so that        they     
    can be used for making further developments in the IR Remote control based       
    projects.
    Copyright (C) 2017  Techduino
    
    Please use 5V SPDT relay for absolute compatibility.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or any   
    latervversion.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see http://www.gnu.org/licenses.
*******************************************************************************/

#include <IRremote.h>      //including infrared remote header file
#include <LiquidCrystal.h>    //including LCD header file

#define code1  16582903   // code received from button 1
#define code2  16615543   // code received from button 2
#define code3  16580863   // code received from "power button"

LiquidCrystal lcd(12,10,7,6,5,4);

int RECV_PIN = 11;        // the pin where you connect the output pin of IR sensor 
IRrecv irrecv(RECV_PIN);
decode_results results;

int app1 = 3;         //fan pin
int app2 = 2;         //bulb pin
int status[] = {0,0};
/* the initial state of appliances is OFF (zero) 
the first zero must remain zero but you can 
change the others to 1's if you want a certain
appliance to be ON when the board is powered;
you can increse the elements in the array to add
more appliances.*/
 
void setup()
{
  Serial.begin(9600);
  lcd.begin(16,2);          // Start the LCD
  irrecv.enableIRIn();        // Start the IR receiver
  
  pinMode(app1, OUTPUT);
  pinMode(app2, OUTPUT);
  
  lcd.setCursor(0,0);     
  lcd.print("Made by Techduino");   // Made by Techduino
  delay(1500);
  lcd.clear();
  
  lcd.setCursor(3,0);
  lcd.print("Arduino IR");      //Arduino IR Switch Board
  lcd.setCursor(2,1);
  lcd.print("Switch Board");
  delay(1500);
  lcd.clear();
  
  lcd.setCursor(0,0);
  lcd.print("(1) Fan : OFF");     //Showing intial status on LCD
  lcd.setCursor(0,1);
  lcd.print("(2) Bulb : OFF");
  
}
 
void loop() 
{
  if (irrecv.decode(&results)) {
    unsigned int value = results.value;
    switch(value) {
      
       case code1:
         if(status[1] == 1) {           // if first app is ON then
            digitalWrite(app1, LOW);      // turn it off when button is pressed
            status[1] = 0;              // and set its state as off
            lcd.setCursor(10,0);      //printing status on LCD
            lcd.print("OFF");
          }
      
        else {                          // else if first app is OFF then
              digitalWrite(app1, HIGH);   // turn it on when the button is pressed
              status[1] = 1;            // and set its state as ON
              lcd.setCursor(10,0);    //printing status on LCD
              lcd.print("ON ");
           }
              break;
      
      
       case code2:
         if(status[2] == 1) {
            digitalWrite(app2, LOW);
            status[2] = 0;
            lcd.setCursor(11,1);      //printing status on LCD
            lcd.print("OFF");
         } 
      
        else {
              digitalWrite(app2, HIGH);
              status[2] = 1;
              lcd.setCursor(11,1);      //printing status on LCD
              lcd.print("ON ");
           }
              break;
              
       case code3:
         if(status[1] == 1 && status[2] == 1) {
            digitalWrite(app1, LOW);      
            status[1] = 0;              
            lcd.setCursor(10,0);      
            lcd.print("OFF");

            digitalWrite(app2, LOW);
            status[2] = 0;
            lcd.setCursor(11,1);      
            lcd.print("OFF");
           }

         else {
               digitalWrite(app1, HIGH);   
               status[1] = 1;            
               lcd.setCursor(10,0);    
               lcd.print("ON ");

               digitalWrite(app2, HIGH);
               status[2] = 1;
               lcd.setCursor(11,1);      
               lcd.print("ON ");
         }
      
    }
    Serial.println(value);      
    irrecv.resume();       // Receive the next value
  }
}

Comments

Similar projects you might like

Sigfox Forest Fire Detector

Project tutorial by Louis Moreau

  • 2,136 views
  • 2 comments
  • 13 respects

TV Tee Shirt

Project showcase by Maddy

  • 3,686 views
  • 1 comment
  • 12 respects

Race Car Dashboard (Online Connectivity)

Project showcase by Team Jatayu

  • 1,925 views
  • 4 comments
  • 7 respects

Arduino Live WiFi Web Scoreboard

Project tutorial by Oli Norwell

  • 2,242 views
  • 0 comments
  • 4 respects
Add projectSign up / Login