IR Project

Show or discuss your existing Home automation project here, so a detailed explanation!.....

IR Project

Postby AshaiRey » Sat Jan 11, 2014 4:06 pm

IR Project
I have a few appliances in different rooms that are controlled via IR. Think of TV sets, settop box, amplifier and LED lamps.
To take control of these i needed just as many remote controles scattered around the house as i have devices.
There had to be a more universal system. This triggered this IR project.

I started with Shirriff's IRremote library for the Arduino.
More info could be found here righto.com/2009/11/ir-bubbles-controlli ... -with.html
As base controller i ordered an Arduino Mega. I know its rather overkill for this project but in the back of my mind
i have the idea that i can use this over capacity later on for other projects. I wired up a receiver setup on breadboard
and took every remote controle i could find and started to record each and every button press in a file. Next i wired
up a IR transmit setup and send out a few codes again to test if they are working, and they did.

In a simple setup you have only one device of each in your house. Put in every room a few IR LED and connect them in parallel.
Blast them with the right signal and your finished. However if you have, like me, two small TV's that are indentical
then both will respond and that is not what you want.

Another problem is reception. The further away the IR led is the weaker the signal and the set just won't respond. To overcome this
last problem i made an 'IR Blaster' for everyroom. Each blaster contains 3 high power wide beam IR leds, 2 high power narrow IR leds
and a small green control led to make visible when a code is send. Each blaster is powered by 12V and controled by an 2n2222
transistor. Because of this higher voltage i needed to seperate this from the 5V powerline used for the Arduino.

The multi room setup i have is solved this way.
blaster.gif
blaster.gif (8.69 KiB) Viewed 5952 times

Please note that the Mega has a different pin numbering

The IR library provide only one pin that can be used to send IR codes. However i want to send IR codes to the blaster i
select based on its location. To do this i made a blaster for each room and switch via a relay the 12V rail to that blaster
circuit. The output of the Arduino is connected to control transistor (2n2222) but only the one that have actually power will
send them out. The one that you use is based on the controle script. To operate the blaster you just send the code information
and the room id, that's it.

Additionally i made a few vbscripts to control everything via VR (voice recognition). Just say "put the television on discovery" and
the script know s in which room the command was said, what type and model of television there is, finds the right code and transmits
it.

Here's the complete Arduino code used
Code: Select all
/*
ZMC ARDUINO v1.0
- IR Control via HomeSeer
  Direction : INPUT
  Format : I, Protocol type, value, bits, location
  IR Output On the 2560 mega this is pin 9 not pin 3

Values for IR protcol_type
#define NEC 1 - In use
#define SONY 2 - In use
#define RC5 3
#define RC6 4 - In use
#define DISH 5
#define SHARP 6
#define PANASONIC 7
#define JVC 8
#define SANYO 9
#define MITSUBISHI 10
#define UNKNOWN -1
*/

#include <IRremote.h>

// these constants won't change:
const byte MAXIRPROTOCOLS  = 10;
const byte MAXIRLOCATIONS  =  5;
// Assign pin numnbers for the locations
int locations[]            = { 0, 22, 23, 25, 24 };
boolean DEBUG              = false;

                     
IRsend irsend;

void setup()
{
  Serial.begin(9600);
  pinMode(9,OUTPUT);       // The library initializes pin 3 as an output
  digitalWrite(9, LOW);    // Since our LED is connected to pin 9,
                           // we initialize it here
 
  for(int i = 0; i < MAXIRLOCATIONS; i++)
  {
    if(locations[i] &gt 0) pinMode(locations[i], OUTPUT);
  }
}


void loop() {
  // Receiving serial data kicks in here
  // Action, byte1, unsigned long, byte3, byte4
  serialReceived();
}

void serialReceived() {
  // I = IR
  // D = Debug On/Off
 
  while (Serial.available() > 0) {
    char Action = Serial.read();
    int Byte1  = Serial.parseInt();
    unsigned long Byte2  = Serial.parseInt();
    int Byte3  = Serial.parseInt();
    int Byte4  = Serial.parseInt();

    if (DEBUG == true)
    {
      Serial.print("Action = ");
      Serial.print(Action);
      Serial.print(" Byte1 = ");
      Serial.print(Byte1);
      Serial.print(" Byte2 = ");
      Serial.print(Byte2);
      Serial.print(" Byte3 = ");
      Serial.print(Byte3);
      Serial.print(" Byte4 = ");
      Serial.println(Byte4);
    }

    switch (Action) {
      case 'D':
          if (Byte1 == 1 )
          {
            DEBUG = true;
            Serial.println("Debugging is ON");
          }
          else
          {
            DEBUG = false;
            Serial.println("Debugging is OFF");
          }
          break;
      case 'I': // IR command
          int location = Byte4;
          location = constrain(location, 1, 8);
          if(locations[location] > 0) {
            digitalWrite(locations[location], HIGH);
            delay(400);
            // Protocol type, value, bits, location
            if ((Byte1 != 0)  && (Byte1 <= MAXIRPROTOCOLS)) {
              // Type, Value, Bits
              DoIR(Byte1, Byte2, Byte3);
            }
            delay(200);
            digitalWrite(locations[location], LOW);
          }
          break;
    }
  }
}

// ===============
// == FUNCTIONS ==
// ===============
void DoIR(int type, unsigned long value, int bits){
  if(DEBUG == true)
  {
      Serial.print(" type = ");
      Serial.print(type);
      Serial.print(" value = ");
      Serial.print(value);
      Serial.print(" bits = ");
      Serial.print(bits);
  }
  if (type == NEC) {
    irsend.sendNEC(value, bits);
  }
  else if (type == SONY) {
    for (int i = 0; i < 3; i++) {
      irsend.sendSony(value, bits);
      delay(40);
    }
  }
  else if (type == RC5) {
    irsend.sendRC5(value, bits);
  }
  else if (type == RC6) {
    irsend.sendRC6(value, bits);
  }
  else {
    Serial.print(type);
    Serial.println(" - Undefined IR type !");
  }
}
Last edited by AshaiRey on Mon Jan 13, 2014 9:51 am, edited 2 times in total.
Bram
AshaiRey
Senior Member
Senior Member
 
Posts: 1301
Joined: February 2009
Location: Netherlands

Re: IR Project

Postby AshaiRey » Sat Jan 11, 2014 4:25 pm

Here's an images of how the blasters in the rooms look like.
I have also white ones.
blaster.jpg
blaster.jpg (70.75 KiB) Viewed 5946 times


And a last look inside the box
ir-system.jpg
ir-system.jpg (102.13 KiB) Viewed 5944 times
Bram
AshaiRey
Senior Member
Senior Member
 
Posts: 1301
Joined: February 2009
Location: Netherlands

Re: IR Project

Postby Digit » Sat Jan 11, 2014 9:07 pm

With multi-room in mind most people will think it will need lots of hardware to accomplish that; but this solutions excels in simplicity IMO 8)
An inspiring DIY project, great!
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

Re: IR Project

Postby vincenttor » Sun Jan 12, 2014 11:50 pm

Very nice project, i am actually also playing with domotica since a little while and we have the light system from busch jeager and the curtains also controllable with IR.
Only i like to be able to control them with domoticz the open source software i found last week.
Anyway , thanks for sharing
vincenttor
Member
Member
 
Posts: 341
Joined: January 2014
Location: Netherlands

Re: IR Project

Postby jeroen_ » Mon Jan 13, 2014 11:40 am

Cool, always awesome to see people come up with their own electronics!

I am glad though that I just needed an IR blaster to control my amplifier's volume, which is only needed when the TV is off as the rest of the time CEC does it's job quite fine.
jeroen_
Member
Member
 
Posts: 105
Joined: February 2013
Location: Switzerland


Return to Home Automation Projects

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron