Header Ads Widget

DIY Arduino IR Remote Home Automation: A Step-by-Step Guide

With the increasing demand for home automation systems, people are constantly looking for affordable and customizable solutions. One such solution is the Arduino IR remote control system, which allows users to control various appliances with just a click of a button. In this article, we will provide a step-by-step guide on how to set up an Arduino IR remote home automation system.



DIY Arduino IR Remote Home Automation

Step 1: Gather the Materials

To build the Arduino IR remote home automation system, you will need the following materials:

QUARTAZ COMPONENTS LINKS :

Arduino board (UNO or Nano)  :  BUYNOW

IR receiver module    :  BUYNOW

IR remote control   :  BUYNOW

Breadboard     :  BUYNOW

Jumper wires    :  BUYNOW

relay  : BUYNOW

AMAZON LINKS :

Arduino board (UNO or Nano)  :  BUYNOW

IR receiver module    :  BUYNOW

IR remote control   :  BUYNOW

Breadboard     :  BUYNOW

Jumper wires    :  BUYNOW

relay  : BUYNOW

Step 2: Set up the Circuit





Step 3: Program the Arduino Board detect IR remote key values

After setting up the circuit, it's time to program the Arduino board. Download and install the Arduino IDE software on your computer, connect the Arduino board to your computer via a USB cable, and open a new sketch. Copy and paste the following code:

#include <IRremote.h>
 
// Define sensor pin
const int RECV_PIN = 2;
 
// Define IR Receiver and Results Objects
IRrecv irrecv(RECV_PIN);
decode_results results;
 
 
void setup(){
  // Serial Monitor @ 9600 baud
  Serial.begin(9600);
  // Enable the IR Receiver
  irrecv.enableIRIn();
}
 
void loop(){
  if (irrecv.decode(&results)){
    // Print Code in HEX
        Serial.println(results.value, HEX);
        irrecv.resume();
  }
}

This code uses the IRremote library to read the IR signal received by the IR receiver module and turn the LED (or any other appliance) on or off based on the signal received.

Step 4: Upload the Code to the Arduino Board

Once you've finished writing the code, upload it to the Arduino board by clicking the "Upload" button in the Arduino IDE software. Wait for the upload to finish, and then disconnect the USB cable.


#include <IRremote.h>

#define relay1 4  
#define relay2 5  
#define relay3 6 
#define relay4 7  

#define switch1 8 
#define switch2 9  
#define switch3 10  
#define switch4 11  

#define IR_RECV_PIN 3 


#define ir_pin1   0x1FE50AF
#define ir_pin2   0x1FED827
#define ir_pin3   0x1FEF807
#define ir_pin4   0x1FE30CF


IRrecv irrecv(IR_RECV_PIN);
decode_results results;

// Switch State
bool SwitchState_1 = LOW;
bool SwitchState_2 = LOW;
bool SwitchState_3 = LOW;
bool SwitchState_4 = LOW;



void relayOnOff(int relay){
 switch(relay){
      case 1:
            digitalWrite(relay1, !digitalRead(relay1)); // change state for relay-1
            
            delay(100);
      break;
      case 2:
            digitalWrite(relay2, !digitalRead(relay2)); // change state for relay-2
            
            delay(100);
      break;
      case 3:
            digitalWrite(relay3, !digitalRead(relay3)); // change state for relay-3
            
            delay(100);
      break;
      case 4:
            digitalWrite(relay4, !digitalRead(relay4)); // change state for relay-4
            
            delay(100);
      break;
      default : break;      
      }  
}


void ir_remote(){
  if (irrecv.decode(&results)) {
    
      switch(results.value){
          case ir_pin1:  relayOnOff(1);     break;
          case ir_pin2:  relayOnOff(2);     break;
          case ir_pin3:  relayOnOff(3);     break;
          case ir_pin4:  relayOnOff(4);     break;
           
          default : break;         
        }   
        Serial.println(results.value, HEX);    
        irrecv.resume();   
  } 
}



void manual_control()
{
  if (digitalRead(switch1) == LOW && SwitchState_1 == LOW) {
    digitalWrite(relay1, LOW);
   
    SwitchState_1 = HIGH;
  }
  if (digitalRead(switch1) == HIGH && SwitchState_1 == HIGH) {
    digitalWrite(relay1, HIGH);
    
    SwitchState_1 = LOW;
  }
  if (digitalRead(switch2) == LOW && SwitchState_2 == LOW) {
    digitalWrite(relay2, LOW);
    
    SwitchState_2 = HIGH;
    Serial.println("Switch-2 on");
  }
  if (digitalRead(switch2) == HIGH && SwitchState_2 == HIGH) {
    digitalWrite(relay2, HIGH);
   
    SwitchState_2 = LOW;
    Serial.println("Switch-2 off");
  }
  if (digitalRead(switch3) == LOW && SwitchState_3 == LOW) {
    digitalWrite(relay3, LOW);
    
    SwitchState_3 = HIGH;
    Serial.println("Switch-3 on");
  }
  if (digitalRead(switch3) == HIGH && SwitchState_3 == HIGH) {
    digitalWrite(relay3, HIGH);
 
    SwitchState_3 = LOW;
    Serial.println("Switch-3 off");
  }
  if (digitalRead(switch4) == LOW && SwitchState_4 == LOW) {
    digitalWrite(relay4, LOW);
   
    SwitchState_4 = HIGH;
    Serial.println("Switch-4 on");
  }
  if (digitalRead(switch4) == HIGH && SwitchState_4 == HIGH) {
    digitalWrite(relay4, HIGH);
  
    SwitchState_4 = LOW;
    Serial.println("Switch-4 off");
  }
}  

void setup() {
  Serial.begin(9600);
 

  irrecv.enableIRIn(); // Start the receiver

  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(relay4, OUTPUT);

  pinMode(switch1, INPUT_PULLUP);
  pinMode(switch2, INPUT_PULLUP);
  pinMode(switch3, INPUT_PULLUP);
  pinMode(switch4, INPUT_PULLUP);

  //During Starting all Relays should TURN OFF
  digitalWrite(relay1, HIGH);
  digitalWrite(relay2, HIGH);
  digitalWrite(relay3, HIGH);
  digitalWrite(relay4, HIGH);
  
  delay(500);
 
}

void loop() {

  ir_remote();

  manual_control();
}



Step 5: Test the System

Finally, it's time to test the system. Point the IR remote control at the IR receiver module and press the "on" button. The LED (or any other appliance) connected to the Arduino board should turn on. If everything works as expected, you can now control your appliances with the IR remote control.


Conclusion:

Building a DIY Arduino IR remote home automation system is an affordable and customizable solution for those looking to automate their homes. By following the step-by-step guide provided in this article, you can easily set up your own system and start controlling your appliances with just a click of a button. With the right optimization and promotion, your article can reach a large audience and provide them with valuable information about Arduino IR remote home automation.






Post a Comment

0 Comments