IR Remote control of Air Conditioner - Can't get it to work

Byork:
JD, sure here's what I did. Both receiving and sending are tested on Uno and Nano.

For receiving the signal, I am using the TSOP4838, connected to pin 2 according to the sketch. After pressing the button on your AC remote, you may need to wait up to 5 seconds for the code to appear in serial monitor. The sketch I used was:

#define LEDPIN 13

//you may increase this value on Arduinos with greater than 2k SRAM
#define maxLen 800

volatile  unsigned int irBuffer[maxLen]; //stores timings - volatile because changed by ISR
volatile unsigned int x = 0; //Pointer thru irBuffer - volatile because changed by ISR

void setup() {
 Serial.begin(115200); //change BAUD rate as required
 attachInterrupt(0, rxIR_Interrupt_Handler, CHANGE);//set up ISR for receiving IR signal
}

void loop() {
 // put your main code here, to run repeatedly:

Serial.println(F("Press the button on the remote now - once only"));
 delay(5000); // pause 5 secs
 if (x) { //if a signal is captured
   digitalWrite(LEDPIN, HIGH);//visual indicator that signal received
   Serial.println();
   Serial.print(F("Raw: (")); //dump raw header format - for library
   Serial.print((x - 1));
   Serial.print(F(") "));
   detachInterrupt(0);//stop interrupts & capture until finshed here
   for (int i = 1; i < x; i++) { //now dump the times
     if (!(i & 0x1)) Serial.print(F("-"));
     Serial.print(irBuffer[i] - irBuffer[i - 1]);
     Serial.print(F(", "));
   }
   x = 0;
   Serial.println();
   Serial.println();
   digitalWrite(LEDPIN, LOW);//end of visual indicator, for this time
   attachInterrupt(0, rxIR_Interrupt_Handler, CHANGE);//re-enable ISR for receiving IR signal
 }

}

void rxIR_Interrupt_Handler() {
 if (x > maxLen) return; //ignore if irBuffer is already full
 irBuffer[x++] = micros(); //just continually record the time-stamp of signal transitions

}




My AC IR code received was this:



Raw: (439) 3552, -1664, 508, -364, 508, -1232, 504, -364, 508, -360, 508, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -1236, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -1232, 508, -1232, 480, -1256, 484, -392, 480, -388, 480, -1256, 484, -388, 480, -388, 480, -392, 504, -364, 480, -388, 508, -360, 508, -364, 480, -388, 504, -364, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -368, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 508, -360, 508, -364, 504, -364, 504, -364, 508, -364, 504, -368, 476, -392, 476, -392, 480, -1256, 484, -1256, 508, -364, 504, -364, 504, -364, 508, -360, 508, -364, 504, -10884, 3528, -1688, 504, -368, 504, -1232, 484, -384, 484, -388, 484, -384, 484, -384, 484, -384, 484, -392, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -1228, 508, -364, 504, -364, 508, -364, 504, -364, 504, -368, 504, -364, 504, -364, 504, -1232, 508, -1232, 508, -1232, 504, -364, 508, -364, 504, -1232, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -1236, 504, -1232, 480, -1260, 484, -384, 484, -384, 484, -384, 484, -388, 484, -384, 508, -368, 476, -1256, 508, -1228, 512, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -1236, 504, -1232, 504, -364, 508, -364, 504, -364, 504, -1236, 504, -1232, 480, -388, 480, -392, 484, -384, 480, -388, 484, -388, 484, -384, 484, -384, 484, -392, 480, -388, 480, -388, 480, -388, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -1232, 504, -1236, 504, -1232, 504, -364, 508, -364, 504, -364, 480, -388, 480, -392, 476, -392, 480, -392, 480, -388, 480, -392, 480, -1252, 512, -1232, 504, -1232, 508, -364, 504, -364, 504, -364, 504, -368, 504, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -368, 472, -396, 476, -392, 476, -392, 476, -396, 476, -1256, 484, -392, 476, -392, 480, -388, 480, -388, 508, -364, 504, -364, 504, -1236, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -368, 500, -368, 500, -368, 476, -396, 476, -392, 476, -392, 476, -1260, 484, -1252, 484, -1260, 480, -388, 504, -364, 508, -364, 504, -1232, 508




You then need to remove all the negative signs using a text editor. After which I used and inserted my IR code into this sketch. The IR emitter LED is connected to pin 3 as according to the sketch:



/*

  • IRremote: IRsendRawDemo - demonstrates sending IR codes with sendRaw
  • An IR LED must be connected to Arduino PWM pin 3.
  • Version 0.1 July, 2009
  • Copyright 2009 Ken Shirriff
  • http://arcfn.com
  • IRsendRawDemo - added by AnalysIR (via www.AnalysIR.com), 24 August 2015
    */

#include <IRremote.h>

IRsend irsend;

void setup()
{

}

void loop() {
 int khz = 38; // 38kHz carrier frequency for the NEC protocol
 unsigned int irSignal[] = {3552, 1664, 508, 364, 508, 1232, 504, 364, 508, 360, 508, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 1236, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 1232, 508, 1232, 480, 1256, 484, 392, 480, 388, 480, 1256, 484, 388, 480, 388, 480, 392, 504, 364, 480, 388, 508, 360, 508, 364, 480, 388, 504, 364, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 368, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 508, 360, 508, 364, 504, 364, 504, 364, 508, 364, 504, 368, 476, 392, 476, 392, 480, 1256, 484, 1256, 508, 364, 504, 364, 504, 364, 508, 360, 508, 364, 504, 10884, 3528, 1688, 504, 368, 504, 1232, 484, 384, 484, 388, 484, 384, 484, 384, 484, 384, 484, 392, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 1228, 508, 364, 504, 364, 508, 364, 504, 364, 504, 368, 504, 364, 504, 364, 504, 1232, 508, 1232, 508, 1232, 504, 364, 508, 364, 504, 1232, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 1236, 504, 1232, 480, 1260, 484, 384, 484, 384, 484, 384, 484, 388, 484, 384, 508, 368, 476, 1256, 508, 1228, 512, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 1236, 504, 1232, 504, 364, 508, 364, 504, 364, 504, 1236, 504, 1232, 480, 388, 480, 392, 484, 384, 480, 388, 484, 388, 484, 384, 484, 384, 484, 392, 480, 388, 480, 388, 480, 388, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 1232, 504, 1236, 504, 1232, 504, 364, 508, 364, 504, 364, 480, 388, 480, 392, 476, 392, 480, 392, 480, 388, 480, 392, 480, 1252, 512, 1232, 504, 1232, 508, 364, 504, 364, 504, 364, 504, 368, 504, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 368, 472, 396, 476, 392, 476, 392, 476, 396, 476, 1256, 484, 392, 476, 392, 480, 388, 480, 388, 508, 364, 504, 364, 504, 1236, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 368, 500, 368, 500, 368, 476, 396, 476, 392, 476, 392, 476, 1260, 484, 1252, 484, 1260, 480, 388, 504, 364, 508, 364, 504, 1232, 508};
 
 irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.

delay(5000); //In this example, the signal will be repeated every 5 seconds, approximately.
}

I am having the same Problem and tried above code also and method but then also it's not working I am getting 439 and 238 long codes. Please Help.

Peace,

For receiving data ===> analysir code
For sending data ====> send raw ( irRemote library )

For arduino mega
Rx (receiver) pin ==== 21
Tx (emitter) pin ===== 9 , (not 2 not 3)

another thank you for post #9...i've spend 2 hours to make IR remote library work...everything looked fine but ir send couldnt work...
analysIR make the trick for my air condition.

edit: this confused me very much, so i write it in case it'll help someone..
my air condition remote controller, doesnt transmit only one ir signal..
it transmits both On and Off signals...
and actually my remote didnt transmit two different signals and toggle between them..so i guess there are many "on" sequences and many "off" sequences that toggle..

I guess its a trial and error to find one ON and one OFF signal that can work..

For me this code worked fine to power on and then shut down my inventor air condition:

(to find these sequences i used receiver post #9 code)

transmitter code

/*
   IRremote: IRsendRawDemo - demonstrates sending IR codes with sendRaw
   An IR LED must be connected to Arduino PWM pin 3.
   Version 0.1 July, 2009
   Copyright 2009 Ken Shirriff
   http://arcfn.com

   IRsendRawDemo - added by AnalysIR (via www.AnalysIR.com), 24 August 2015
*/


#include <IRremote.h>

IRsend irsend;

void setup()
{
  Serial.begin(115200);
}

void loop() {
  int khz = 38; // 38kHz carrier frequency for the NEC protocol
  
  unsigned int irSignalClose[] = {
    4360,  4416, 508,  1672, 508,  588, 508,  1676, 512,  1668, 512,  580, 512,  584, 508,  1672, 508,  588, 508,  584, 512,  1672, 512,  584, 508,  584, 508,  1672, 508,  1672, 536,  560, 536,  1648, 512,  584, 508,  1672, 512,  1668, 512,  1668, 536,  1644, 540,  552, 512,  1672, 512,  1672, 536,  1652, 508,  584, 536,  556, 540,  552, 540,  556, 536,  1644, 536,  556, 512,  584, 512,  1672, 536,  1644, 512,  1668, 540,  552, 512,  584, 536,  556, 508,  584, 512,  584, 512,  584, 508,  584, 536,  560, 508,  1672, 512,  1668, 512,  1668, 512,  1668, 508,  1672, 476,  5312, 4360,  4416, 512,  1668, 512,  584, 508,  1672, 512,  1668, 536,  560, 508,  584, 508,  1672, 508,  588, 536,  560, 508,  1672, 536,  560, 508,  584, 508,  1672, 508,  1672, 508,  584, 508,  1680, 508,  588, 508,  1668, 512,  1668, 512,  1668, 512,  1668, 508,  584, 512,  1672, 508,  1672, 512,  1676, 508,  584, 508,  584, 512,  584, 508,  584, 508,  1672, 508,  584, 508,  588, 512,  1672, 512,  1668, 508,  1672, 508,  584, 508,  588, 508,  584, 508,  584, 508,  588, 508,  588, 508,  584, 508,  584, 508,  1676, 508,  1672, 508,  1672, 508,  1668, 512,  1672, 456,
  };

  unsigned int irSignalOpen[] = {
    4328,  4464, 512,  1668, 508,  584, 536,  1648, 536,  1640, 536,  556, 512,  580, 540,  1640, 508,  588, 540,  556, 508,  1672, 536,  556, 516,  580, 508,  1668, 536,  1644, 508,  584, 512,  1672, 508,  1676, 512,  584, 536,  1644, 508,  1672, 536,  1640, 516,  1664, 536,  1644, 508,  1672, 508,  588, 536,  1640, 536,  556, 536,  560, 536,  556, 508,  584, 508,  584, 512,  584, 508,  1676, 508,  1668, 512,  584, 508,  584, 508,  1672, 504,  1672, 508,  584, 508,  588, 508,  588, 508,  584, 508,  1672, 512,  1668, 508,  584, 508,  584, 508,  1672, 536,  1644, 476,  5308, 4356,  4416, 536,  1640, 508,  588, 508,  1672, 508,  1672, 508,  584, 512,  580, 512,  1668, 508,  588, 508,  584, 508,  1676, 536,  556, 508,  584, 508,  1672, 512,  1664, 508,  584, 512,  1672, 536,  1652, 504,  588, 508,  1672, 508,  1672, 508,  1672, 504,  1672, 512,  1668, 508,  1672, 508,  588, 480,  1696, 508,  584, 512,  584, 508,  584, 508,  584, 508,  588, 504,  588, 508,  1676, 508,  1668, 508,  588, 504,  588, 508,  1668, 508,  1672, 508,  584, 508,  588, 508,  584, 508,  584, 512,  1672, 508,  1668, 512,  584, 508,  584, 508,  1668, 484,  1700, 476,
  };
  
  Serial.println("Open");
  irsend.sendRaw(irSignalOpen, sizeof(irSignalOpen) / sizeof(irSignalOpen[0]), khz); //Note the approach used to automatically calculate the size of the array.
  delay(7000); //In this example, the signal will be power on the air condition for 7 seconds and then shut it down for another 7 seconds
  
  Serial.println("Close");
  irsend.sendRaw(irSignalClose, sizeof(irSignalClose) / sizeof(irSignalClose[0]), khz);
  delay(7000);
}

Wow Byork awesome trick :smiley:
I made work my Daikin AC thanks to your solution!
Tanks you very much!!!

Hi, I've got a problem on sending the raw signal. I also have tried using the AC remote and phone remote. The AC remote gave 175 buffer size. While the phone remote gave 279 int length. And both are not working, AC still off. I used the analysIR code both to receive and sending raw data. If anybody could help me, I would be grateful. Thank you

Hi!

I've tried to use another AC and got 439 int length. But, the AC still doesn't respond. I've also tried to increase the NEC frequency to 44 and it doesn't work as well. Any suggestion?

@Byork Thank you for the detailed post. This process worked on my AC.
Have been racking my brains for the past week.