Vilém Kužel
Published © GPL3+

IR Remote Controlled Power Switch for Rapsberry Pi 3

Arduino Nano based relay power switch for Raspberry Pi 3 (Kodi) operated by common TV remote controller.

BeginnerFull instructions provided1 hour8,034
IR Remote Controlled Power Switch for Rapsberry Pi 3

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Relay Module (Generic)
×1
IR receiver (generic)
×1
LED (generic)
LED (generic)
×1
Resistor 221 ohm
Resistor 221 ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

Wiring diagram

Please note relay module was used (not relay shield)

Code

IR controlled relay switch based on Arduino Nano

Arduino
Original code is based on this project - http://www.instructables.com/id/Arduino-Infrared-Remote-tutorial/ - which I extended and tailored.
#include <IRremote.h>

/*
 * Credits - http://www.instructables.com/id/Arduino-Infrared-Remote-tutorial/
 * TV Samsung remote codes
 * AD     - E0E0E41B - 3772834843 or 37A03AA2 - 933247650
 * SUBT.  - E0E0A45B - 3772818523 or A51FEC3E - 2770332734
*/

//Relay PIN
#define relePIN 12

//IR sensor PIN
int RECV_PIN = 11;

//Control LED PIN
int LED_PIN = 10;

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  pinMode(relePIN, OUTPUT);
  pinMode(LED_PIN, OUTPUT);
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop()
{
  if (irrecv.decode(&results))
  {
    Serial.print(results.value, HEX);
    Serial.print(" - ");
    Serial.println(results.value);
    if (results.value == 3772834843 || results.value == 933247650){
      digitalWrite(relePIN, HIGH); // Relay ON
      digitalWrite(LED_PIN, HIGH); // LED ON
    } 
    if (results.value == 3772818523 || results.value == 2770332734){
      digitalWrite(relePIN, LOW); // Relay OFF
      digitalWrite(LED_PIN, LOW); // LED OFF
    } 
    irrecv.resume(); // Receive the next value
  }
}

Credits

Vilém Kužel

Vilém Kužel

7 projects • 22 followers
https://www.linkedin.com/in/vilemkuzel/

Comments