IR for control Air Conditioner

Hello ,
I want to make a simple project that turn my Air Conditioner ON\Off using Arduino
I know there is a different between the IR I , how do I know which one to use? 850n\730\940nm?

after I will know which one to use -
how do I know the code for on\off? can I "read" the data from the original remote control?

is there any thing else I would need for this project except Arduino&IR sender&button ?

Thanks,

What model of aircon?
Try doing a google search for "arduino ir remote control air conditioner" to see possible answers to your problem.

I have found this

but it didn't say which IR led I should use
I understand there is a different , so how do I know which one to use?

Thanks ,

david1234:
I have found this
http://www.instructables.com/id/How-to-control-the-air-conditioner-AC-at-home-with/
but it didn't say which IR led I should use
I understand there is a different , so how do I know which one to use?

Assuming your aircon is using the same type of remote then it's probably in the 940nm range.
Something like this will do the job but be aware an IR LED draws a lot more current than the average visible LED so to get the full range for your remote you may need to drive the IR LED through a transistor.

o.k.
if it said that the Arduino Digital Output can provide 40mA
and the max use of the IR lED is 50mA
so it won't work? or it only work for small distance ? for example up to 10cm instead of 30cm for 50mA (the numbers are not correct - just to give an idea ?)

also if I want to use a transistor to make the IR LED work - I will have to connect it to an external 5V right? not to the I|O Pins

Thanks ,

Yes the Arduino pins are rated to a MAX of 40mA but 20-25mA is a safer margin.

The LED will still work but as you surmise the range will be reduced.

To use a transistor to switch the IR on/off you can power it from the 5V pin of your Arduino.
The method would be like this...

but the resistor values may need changing to suit your particular IR LED.

o.k.
Thanks,
I will see what kind of IR LED I will have in the store and then i will ask you again

Thanks ,

david1234:
I will see what kind of IR LED I will have in the store and then i will ask you again

To test with you might not need the transistor, depends on what size room your in.

the test will be on the desk - maybe 1m

if I get this part - it good right?
http://www.ebay.com/itm/IR-Wireless-Remote-Control-Infrared-Module-Kits-Suit-For-Arduino-AVR-PIC-Gadgets/291483243700?_trksid=p2047675.c100009.m1982&_trkparms=aid%3D777000%26algo%3DABA.MBE%26ao%3D1%26asc%3D20131227121020%26meid%3Dbabfcc28c7044aa896647aa5a48c0b85%26pid%3D100009%26rk%3D1%26rkt%3D1%26sd%3D141684489083

and I get both receiver , IR LED , and remote ,

and if all will work and I would like to work in bigger distance (5-8m) I will get he NPN transistor ,
Thanks ,

All remote control are usually from 850 ~ 950nm there is no big difference the only difference is you actually can see in the dark the 850 just a little flashing but you can't see the 950nm.
to make your own remote control you need 1st to read with a Infrared receiver each button of your remote control code after reading the code you will be able to rewrite your arduino code and plug a Infrared "transmiter" led, they are mostly called just IR leds. After that from your arduino code you will be able to
(press a button) and turn on/off your air conditioner.

You can follow this tutorial step by step, it's easy to understand and you will figure out what components you
need and what exactly to do:

I done that in the past and worked really well.

Have fun,
Domino60 :slight_smile:

O.k.
i have bought the item from eBay - so now i will just wait till it came

I will ask again if I will have any problem after I will receive the item

Thanks ,

I have got the IR remote+receiver
upload the code as written here - Using an IR Sensor | IR Sensor | Adafruit Learning System

and I can see it's working
but what does it mean to me

when I press "OK"
this is what I get

Received: 

OFF 	ON
41596 usec, 8740 usec
4300 usec, 520 usec
560 usec, 560 usec
520 usec, 560 usec
540 usec, 540 usec
540 usec, 540 usec
540 usec, 560 usec
540 usec, 540 usec
540 usec, 540 usec
540 usec, 560 usec
1620 usec, 540 usec
1640 usec, 540 usec
1580 usec, 600 usec
1640 usec, 540 usec
1620 usec, 540 usec
1640 usec, 540 usec
1640 usec, 560 usec
1620 usec, 520 usec
560 usec, 560 usec
540 usec, 540 usec
540 usec, 560 usec
520 usec, 560 usec
540 usec, 540 usec
540 usec, 540 usec
1640 usec, 540 usec
540 usec, 560 usec
1620 usec, 520 usec
1660 usec, 540 usec
1640 usec, 540 usec
1640 usec, 540 usec
1640 usec, 540 usec
1640 usec, 540 usec
540 usec, 540 usec
1640 usec, 540 usec
38100 usec, 8740 usec
2120 usec, 520 usec
27144 usec, 8740 usec
2120 usec, 580 usec
int IRsignal[] = {
// ON, OFF (in 10's of microseconds)
	874, 430,
	52, 56,
	56, 52,
	56, 54,
	54, 54,
	54, 54,
	56, 54,
	54, 54,
	54, 54,
	56, 162,
	54, 164,
	54, 158,
	60, 164,
	54, 162,
	54, 164,
	54, 164,
	56, 162,
	52, 56,
	56, 54,
	54, 54,
	56, 52,
	56, 54,
	54, 54,
	54, 164,
	54, 54,
	56, 162,
	52, 166,
	54, 164,
	54, 164,
	54, 164,
	54, 164,
	54, 54,
	54, 164,
	54, 3810,
	874, 212,
	52, 2714,
	874, 212,
	58, 0};

so what can I understand from it ? ,
what do I take from all this data in order to build my own code ?

when press "OK" led1 in on ? (for example0

Thanks ,

Download and install the IRremote library and try the below code. I cannot remember where it came from to link you directly to it so just posted the code here.

#include "IRremote.h"

int receiver = 8;

IRrecv irrecv(receiver);           // create instance of 'irrecv'
decode_results results;            // create instance of 'decode_results'

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


void loop()
{
  if (irrecv.decode(&results)){ // have we received an IR signal?
    translateIR(); 
    irrecv.resume(); // receive the next value
  }  
}

void translateIR(){ // takes action based on IR code received
  
  switch(results.value){
    case 0x00511DBB: Serial.println(" FORWARD"); break;
    case 0x52A3D41F: Serial.println(" LEFT");    break;
    case 0xFF02FD: Serial.println(" -OK-");    break;
    case 0xFFC23D: Serial.println(" RIGHT");   break;
    case 0xFFA857: Serial.println(" REVERSE"); break;
    case 0xFF6897: Serial.println(" 1");    break;
    case 0xFF9867: Serial.println(" 2");    break;
    case 0xFFB04F: Serial.println(" 3");    break;
    case 0xFF30CF: Serial.println(" 4");    break;
    case 0xFF18E7: Serial.println(" 5");    break;
    case 0xFF7A85: Serial.println(" 6");    break;
    case 0xFF10EF: Serial.println(" 7");    break;
    case 0xFF38C7: Serial.println(" 8");    break;
    case 0xFF5AA5: Serial.println(" 9");    break;
    case 0xFF42BD: Serial.println(" *");    break;
    case 0xFF4AB5: Serial.println(" 0");    break;
    case 0xFF52AD: Serial.println(" #");    break;
    //case 0xFFFFFFFF: Serial.println(" REPEAT");break;  
    case 0xFFFFFFFF: break;  
    
    default: 
    Serial.print(" Uknown ");
    Serial.println(results.value, HEX);
  }
}

O.k.

now I can decode the signal

but I can't save it -

this is what I have for now

 #include <IRremote.h>
#include <IRremoteInt.h>
#include <SoftwareSerial.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // set the LCD address to 0x20 for a 16 chars and 2 line display


int RECV_PIN = 6;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.print("Initializes!");
    for(int i = 0; i< 3; i++)
  {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight(); // finish with backlight on 
   lcd.setCursor(0,1);
  lcd.print("IR");
   Serial.println ("DONE!!");
  }

void loop()
{
  int temp;
  if (irrecv.decode(&results))
    {
     Serial.println(results.value, HEX);
     temp=(results.value, HEX);
     irrecv.resume(); // Receive the next value
    }
   lcd.setCursor(0,1);//
   lcd.clear();
   lcd.print(results.value, HEX);
   
   if ((results.value,HEX)=='FF02FD')
  {
    Serial.println ("You have just press OK ");
     }
  
}

I can see in the Serial monitor and also on the LCD that I'm getting FF02FD
but when I print "temp" I don't see the value FF02FD
how do I save it as a value that I can "play" with him?
I'm guessing this is a converting issue?

so I want to be able to turn on led when I press O.K (FF02FD0 - for example

Thanks ,

O.k.
I understand what I need to do
found on the internet that I need to change from Hex to Decimal
now it's working

Thanks for all the help !

sorry ,
I have 1 more question now
I also want to use IR sender ( I have IR LED )
this is what I have done

#include <IRremote.h>
#include <IRremoteInt.h>
#include <SoftwareSerial.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // set the LCD address to 0x20 for a 16 chars and 2 line display


int RECV_PIN = 6;
IRsend irsend;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.print("Initializes!");
  for(int i = 0; i< 3; i++)
  {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight(); // finish with backlight on 
  lcd.setCursor(0,1);
  lcd.print("IR");
  Serial.println ("DONE!!");
  lcd.clear();
  lcd.print("  You press - ");
}

void loop()
{
  int temp;
  if (irrecv.decode(&results))
  {
    Serial.println(results.value);
    irrecv.resume(); // Receive the next value
  }
  //lcd.setCursor(0,1);
  //lcd.print(results.value, HEX);

  switch (results.value)
  {
  case 16712445:
    {
      Serial.println("yehhhhhhhhhhhhhh babay! - O.K");
      lcd.setCursor(0,1);
      lcd.print("    O.K    ");
      break;
    }
  case 16738455:
    {
      Serial.println("1");
      lcd.setCursor(0,1);
      lcd.print("    1    ");
      break;
    }
  case 16750695:
    {
      Serial.println("2");
      lcd.setCursor(0,1);
      lcd.print("    2    ");
      Serial.println("going to send O.K now  - ");
      irsend.sendAiwaRCT501(0xFF02FD);
      delay (2000);
      Serial.println("Done");
      break;
    }
  case 16728765:
    {
      Serial.println("*");
      lcd.setCursor(0,1);
      lcd.print("    *    ");
      break;
    }
  case 16732845:
    {
      Serial.println("#");
      lcd.setCursor(0,1);
      lcd.print("    #    ");
      break;
    }

  }//end case 


}//end loop

so when I press "2" it will send me the code for O.K.

but it doesn't work for me -
the IR LED connected to PIN3 (this is what I have found online, but it didn't say where to declare it )

Thanks ,

david1234:
I can see in the Serial monitor and also on the LCD that I'm getting FF02FD
but when I print "temp" I don't see the value FF02FD
how do I save it as a value that I can "play" with him?
I'm guessing this is a converting issue?

Your problem here is you have defined 'temp' as an int value that can only hold a value up/down to 0xFFFF
use 'unsigned long' instead and it will hold the correct values (up to 0xFFFFFFFF).

david1234:
sorry ,
I have 1 more question now
I also want to use IR sender ( I have IR LED )

so when I press "2" it will send me the code for O.K.

but it doesn't work for me -
the IR LED connected to PIN3 (this is what I have found online, but it didn't say where to declare it )

Your sample code is sending AiwaRCT501 protocol signals but is the remote control you using sending this type of remote protocol to you?

Try running the 'IRrecvDump.ino' example sketch and it should tell you what the protocol used is and then you may need to alter the sending protocol.

I'm running the IRrecvDump ,and pointing the remote control to it
but I get many results

C3E16F1C
Decoded NEC: C3E16F1C (32 bits)
Raw (101): 12312 9000 -4500 600 -1650 550 -1700 600 -600 600 -600 600 -600 600 -600 600 -1650 600 -1650 600 -1700 550 -1700 600 -1700 550 -600 600 -600 550 -600 600 -600 600 -1700 600 -550 650 -1700 500 -1700 600 -600 600 -1700 550 -1700 600 -1650 600 -1700 600 -550 650 -600 600 -600 600 -1650 550 -1700 600 -1650 600 -600 600 -600 550 -600 600 -600 600 -600 600 -550 600 -600 600 -600 550 -1700 600 -650 550 -600 600 -600 600 -600 600 -600 600 -550 600 -650 600 -550 650 -600 550 -600 
FFFFFEFF
Decoded AIWA RC T501: FFFFFEFF (48 bits)
Raw (101): -5770 8950 -4550 550 -1700 500 -1750 500 -700 600 -600 550 -650 550 -650 500 -1750 500 -1750 550 -1750 550 -1700 500 -1750 600 -600 500 -700 550 -600 550 -650 550 -1750 550 -600 600 -1700 500 -1750 550 -600 650 -1700 500 -1700 600 -1700 550 -1700 600 -600 650 -550 600 -600 600 -1700 550 -1650 650 -1650 600 -550 650 -600 500 -650 550 -650 500 -650 550 -650 500 -650 550 -650 500 -1750 550 -650 650 -600 600 -550 650 -550 650 -550 650 -550 600 -600 600 -600 600 -600 650 -550 
DA9F733E
Unknown encoding: DA9F733E (32 bits)
Raw (101): 15538 9000 -4550 550 -1700 500 -1700 650 -600 550 -650 550 -600 600 -600 550 -1750 500 -1750 550 -1700 600 -1700 550 -1700 600 -550 550 -650 650 -600 500 -650 550 -1750 500 -650 550 -1750 550 -1700 600 -600 550 -1750 550 -1700 550 -1700 600 -1700 600 -600 550 -600 550 -650 550 -1700 550 -1700 600 -1700 500 -700 600 -600 550 -650 550 -650 550 -650 500 -650 550 -650 550 -650 550 -1750 450 -700 550 -600 600 -600 550 -650 550 -600 550 -650 550 -600 550 -650 600 -600 550 -650 
FFFFFF7F
Decoded AIWA RC T501: FFFFFF7F (47 bits)
Raw (101): -14718 8950 -4550 550 -1700 500 -1750 550 -650 600 -600 550 -650 500 -650 600 -1700 500 -1750 550 -1700 600 -1700 550 -1700 600 -600 550 -650 550 -600 550 -650 550 -1700 550 -650 600 -1700 500 -1750 500 -650 650 -1700 500 -1700 550 -1750 550 -1700 550 -650 650 -550 600 -600 550 -1750 500 -1700 600 -1700 600 -550 600 -600 600 -600 550 -650 550 -600 550 -650 550 -600 550 -650 600 -1650 600 -600 650 -600 550 -600 550 -650 550 -650 550 -650 550 -650 500 -700 550 -650 550 -600 
FFFFFEFF
Decoded AIWA RC T501: FFFFFEFF (48 bits)
Raw (101): -28356 9000 -4550 550 -1700 550 -1700 550 -650 550 -650 550 -650 450 -650 600 -1700 550 -1700 600 -1700 600 -1650 600 -1650 650 -600 500 -650 600 -600 550 -650 550 -1750 550 -600 600 -1650 550 -1750 550 -600 600 -1700 550 -1700 650 -1650 600 -1650 600 -600 550 -650 600 -600 550 -1700 550 -1700 550 -1750 550 -600 550 -650 600 -600 550 -600 600 -600 550 -650 550 -600 550 -650 550 -1700 550 -650 650 -550 600 -600 550 -650 550 -650 550 -650 550 -600 600 -600 600 -600 550 -650 
C3E16F1
Decoded LG: C3E16F1 (28 bits)
Raw (101): 6878 9000 -4500 600 -1650 550 -1700 600 -600 600 -600 600 -600 600 -600 600 -1650 600 -1650 600 -1700 550 -1700 600 -1650 600 -600 600 -600 550 -600 600 -600 550 -1700 600 -600 600 -1700 550 -1700 600 -550 650 -1700 550 -1650 600 -1700 550 -1700 600 -600 650 -550 600 -600 600 -1700 550 -1650 600 -1700 600 -550 600 -650 550 -600 600 -600 550 -600 600 -600 550 -600 550 -600 600 -1650 650 -600 600 -600 600 -550 600 -600 600 -600 600 -600 600 -600 600 -600 600 -600 600 -550 
FFFFFEFF
Decoded AIWA RC T501: FFFFFEFF (48 bits)
Raw (101): 11072 9000 -4500 600 -1650 550 -1700 600 -600 600 -600 600 -600 600 -600 600 -1650 550 -1700 550 -1700 650 -1650 600 -1650 600 -600 600 -600 600 -600 550 -650 600 -1700 500 -600 600 -1700 550 -1700 600 -600 600 -1700 600 -1650 600 -1650 600 -1750 550 -600 550 -600 600 -600 600 -1650 600 -1700 550 -1700 600 -600 600 -600 600 -600 600 -600 600 -600 600 -600 600 -600 550 -600 600 -1700 550 -600 600 -600 550 -600 600 -600 600 -600 550 -600 600 -600 550 -650 550 -600 600 -600 
C3E16F1C
Decoded NEC: C3E16F1C (32 bits)
Raw (101): 10536 9000 -4500 600 -1650 600 -1650 600 -600 600 -600 600 -600 600 -600 600 -1650 600 -1650 600 -1700 550 -1700 600 -1700 550 -600 600 -600 550 -600 650 -600 550 -1650 600 -600 600 -1650 550 -1700 600 -600 600 -1700 550 -1650 650 -1650 600 -1650 650 -550 650 -600 600 -550 650 -1650 550 -1700 600 -1650 600 -600 600 -600 550 -600 600 -600 600 -550 650 -550 600 -600 600 -550 600 -1700 600 -600 600 -600 600 -600 600 -600 600 -550 650 -550 600 -600 600 -550 600 -600 600 -600 
FFFFFEFF
Decoded AIWA RC T501: FFFFFEFF (48 bits)
Raw (101): 24838 9000 -4500 600 -1650 600 -1650 600 -600 550 -650 550 -650 500 -650 550 -1700 550 -1700 650 -1650 600 -1650 600 -1700 600 -600 550 -650 550 -650 500 -650 600 -1700 600 -600 550 -1700 500 -1750 600 -600 500 -1750 600 -1650 650 -1700 550 -1700 550 -1700 650 -550 550 -650 550 -1750 550 -1700 550 -1700 600 -600 600 -600 600 -600 550 -650 550 -650 550 -650 500 -650 550 -650 550 -1750 550 -600 600 -600 550 -650 550 -600 550 -650 550 -600 550 -650 550 -600 550 -650 600 -600 
C3E1
Decoded JVC: C3E1 (16 bits)
Raw (101): 1330 9050 -4500 600 -1650 600 -1650 600 -600 600 -550 600 -600 550 -600 500 -1750 550 -1750 550 -1750 500 -1750 500 -1750 600 -600 600 -600 600 -600 600 -600 600 -1700 500 -650 550 -1700 550 -1750 500 -650 550 -1750 500 -1750 600 -1700 500 -1750 500 -1750 600 -650 500 -650 550 -1750 500 -1750 550 -1750 600 -600 550 -650 550 -650 550 -650 500 -650 550 -650 550 -650 550 -650 550 -1750 500 -650 550 -600 550 -650 550 -650 500 -650 550 -650 550 -650 500 -650 550 -650 500 -700 
6D0C6D44
Unknown encoding: 6D0C6D44 (32 bits)
Raw (101): 18716 9000 -4550 550 -1700 550 -1700 550 -650 550 -600 600 -600 500 -650 600 -1650 550 -1750 600 -1700 550 -1700 550 -1700 600 -600 600 -600 600 -600 550 -650 550 -1750 550 -600 550 -1700 600 -1700 550 -600 600 -1650 600 -1700 600 -1700 550 -1700 600 -1650 650 -600 600 -550 600 -1700 600 -1650 600 -1650 650 -600 600 -600 600 -550 650 -550 600 -600 600 -600 550 -650 500 -650 550 -1750 500 -700 500 -650 550 -650 550 -600 550 -650 550 -600 600 -600 600 -600 600 -600 600 -550

so how do I know what to take?

I have try 3 others remotes (for my TV and 2 more AC) - and when I press a button I can see the code. meaning I get the same code every time.
just with this remote I get different code every time

is there something I can do about it? or there is a problem with the remote?
(the remote is working good with the AC - so it's not broken or something)

Thanks ,

1 more question,
I took another remote and I get "Unknown encoding " , but with a constant code
how do I send it ?

9634E292
Unknown encoding: 9634E292 (32 bits)
Raw (101): -14860 2950 -3950 1850 -1000 950 -1900 1900 -950 900 -1000 900 -1000 900 -1000 950 -950 1000 -900 900 -1950 1900 -950 950 -1900 1950 -900 950 -950 950 -950 950 -950 950 -950 950 -950 950 -1000 900 -1000 900 -1000 900 -1000 900 -1000 900 -1000 900 -1000 900 -1000 900 -1000 950 -1000 900 -1950 1950 -900 2950 -3950 1900 -950 900 -1950 1900 -950 950 -950 950 -950 1000 -900 900 -1000 900 -1050 900 -1950 1850 -1000 900 -1950 1900 -950 900 -1000 950 -950 950 -950 950 -950 1000 -950 900 -1000 900 -1000

I understand I need to do this command

irsend.sendRaw(20048274,32,38);

but it doesn't work , so I guess I need to send the Raw - how do I do this ?

Thanks ,

If your IR remote seems to be sending out several different protocols but other remote controls work properly then maybe you need to give more details on this remote as it does not seem to be working properly.

The protocol you would use would correspond with matching number the other sketch gets. Press the OK button and see the codes returned and check if any match the expected code for OK, then use that protocol.

The newer IR library has changed a lot since I last downloaded it and seems somewhat bloated now. It looks like the IRrecvDumpV2.ino will print out program code data for the remote signals it receives so you can just copy and past them into your own program.
Have a look here and google search for ideas and pointers on correct way to use sendRaw.