Sending Infrared to aircon runs for a long time

Hi all,

I've done some tests with replicating and sending IR signals for my TV which worked just fine. And example of mute and unmute for my TV was 68 codes, but now I'm trying to send signals to my aircon which is not working.

I managed to receive the aircon codes which were 439 codes. Much much longer than the TV codes as expected. But I got the full set and sending same as the TV. I'm suspicious of what's going on, cos when I press the actual remote button, it takes only ~1 second to send to the aircon and get the beep confirmation. But when I send it with the Arduino, it takes 14 seconds to send all 439 codes and the aircon does not react at all.

Any ideas if I'm doing something wrong here?

The code is fairly short and simple:

#include <IRremote.h>

IRsend irsend;
//Aircon On
int codeCount = 439;
unsigned int rawCodes[439] = {63840,440,65108,440,64244,468,65136,440,65112,440,65108,468,65136,440,65112,412,65080,440,65112,468,65136,464,65108,440,65108,440,65112,440,64244,468,65136,436,65108,444,65112,444,65112,440,65112,440,65108,440,65112,444,64248,412,64216,440,64240,468,65140,468,65108,436,64240,436,65108,440,65108,440,65112,440,65108,440,65108,436,65108,412,65080,440,65112,440,65108,440,65112,440,65108,436,65104,436,65108,440,65084,444,65112,436,65108,440,65108,440,65112,416,65084,440,65108,440,65112,440,65108,440,65112,440,65108,440,65108,436,65108,444,65112,468,65112,440,65112,444,65112,444,64248,468,64272,440,65108,436,65104,440,65112,444,65112,436,65108,412,55528,3528,63836,440,65112,444,64244,464,65108,440,65108,436,65108,440,65112,440,65108,444,65112,436,65108,444,65112,440,65112,468,65136,440,65112,444,64244,436,65108,440,65108,468,65112,440,65108,468,65140,444,65112,468,65140,444,64248,440,64240,436,64244,472,65140,472,65140,440,64244,440,65112,444,65112,440,65108,436,65108,444,65112,464,65108,440,65108,440,65112,440,65108,440,65112,472,65140,440,65112,440,65108,440,64244,468,64272,440,64244,440,64244,472,65140,440,65108,440,64244,496,65140,468,65136,440,65112,440,64244,440,64240,436,64240,440,64244,440,65112,444,65112,440,65112,444,65112,440,65108,440,65112,440,65108,440,65112,440,65108,468,64244,468,64272,436,65108,440,64240,440,65112,440,64244,440,64244,468,64272,444,65112,468,64272,440,65108,436,65108,468,64272,444,65112,440,65108,440,65112,468,65112,444,65112,440,65108,436,65108,468,65136,440,65112,468,65136,440,65112,452,65120,440,65108,440,64244,440,64244,464,64268,440,65112,440,65108,468,65112,440,65108,440,65108,440,65112,440,65108,440,65112,440,65108,440,64244,468,64272,440,64244,468,65140,444,65112,440,65108,440,65112,440,65108,440,65084,440,65108,440,65112,440,65108,440,65112,444,65112,440,65108,468,65140,444,65112,440,65112,444,65112,440,64244,440,65108,440,65112,468,64272,468,65108,440,65112,444,65116,444,64244,440,65112,468,65136,440,65112,444,65112,440,65108,440,65112,444,65112,468,65140,444,65112,440,65112,468,65108,468,65140,444,65112,440,65112,468,65136,444,65116,472,65140,468,64272,440,64244,440,65108,468,65136,440,65112,468,65140,464,65132,472};

////Mute TV
//int codeCount = 68;
//unsigned int rawCodes[68] = {4400,4450,600,1600,600,1600,600,1650,600,550,550,600,450,650,450,600,500,550,550,1700,550,1650,600,1600,600,550,550,600,450,600,550,550,550,550,500,1700,600,1600,600,1650,600,1600,600,550,550,600,450,550,600,550,550,550,550,550,550,550,550,550,550,1650,600,1650,550,1650,600,1600,600};

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  irsend.sendRaw(rawCodes, codeCount, 38);
  digitalWrite(LED_BUILTIN, LOW);

  Serial.println("Sent the code");
  delay(5000);
}

TIA

Those air-conditioning values look strange. The IRremote library measures pulses with a 50-microsecond clock. That is why all the values in the TV code are multiples of 50. The values in the air conditioning code are both not multiples of 50 and every second number is HUGE. I suspect that they are coded differently, possibly negative numbers to signify the OFF part of the cycle.

Where did you get the air conditioner values?

I guess that the huge values actually should be small negatives, signed instead of unsigned int.

DrDiettrich:
I guess that the huge values actually should be small negatives, signed instead of unsigned int.

Probably, but I don't think the IRremote library uses negative numbers AND they still aren't multiples of 50 so they were not measured by the IRremote library.
Converting the unsigned ints to signed ints and taking the the absolute value gives you this:

unsigned int rawCodes[439] = {
1695, 440, 427, 440, 1291, 468, 399, 440, 423, 440, 427, 468, 399, 440, 423, 412, 455, 440, 
423, 468, 399, 464, 427, 440, 427, 440, 423, 440, 1291, 468, 399, 436, 427, 444, 423, 444, 
423, 440, 423, 440, 427, 440, 423, 444, 1287, 412, 1319, 440, 1295, 468, 395, 468, 427, 436, 
1295, 436, 427, 440, 427, 440, 423, 440, 427, 440, 427, 436, 427, 412, 455, 440, 423, 440, 427, 
440, 423, 440, 427, 436, 431, 436, 427, 440, 451, 444, 423, 436, 427, 440, 427, 440, 423, 416, 
451, 440, 427, 440, 423, 440, 427, 440, 423, 440, 427, 440, 427, 436, 427, 444, 423, 468, 423, 
440, 423, 444, 423, 444, 1287, 468, 1263, 440, 427, 436, 431, 440, 423, 444, 423, 436, 427, 
412, 10007, 3528, 1699, 440, 423, 444, 1291, 464, 427, 440, 427, 436, 427, 440, 423, 440, 427, 444, 423, 436, 427, 444, 423, 440, 423, 468, 399, 440, 423, 444, 1291, 436, 427, 440, 427, 468, 
423, 440, 427, 468, 395, 444, 423, 468, 395, 444, 1287, 440, 1295, 436, 1291, 472, 395, 472, 
395, 440, 1291, 440, 423, 444, 423, 440, 427, 436, 427, 444, 423, 464, 427, 440, 427, 440, 423, 
440, 427, 440, 423, 472, 395, 440, 423, 440, 427, 440, 1291, 468, 1263, 440, 1291, 440, 1291, 
472, 395, 440, 427, 440, 1291, 496, 395, 468, 399, 440, 423, 440, 1291, 440, 1295, 436, 1295, 
440, 1291, 440, 423, 444, 423, 440, 423, 444, 423, 440, 427, 440, 423, 440, 427, 440, 423, 440, 
427, 468, 1291, 468, 1263, 436, 427, 440, 1295, 440, 423, 440, 1291, 440, 1291, 468, 1263, 
444, 423, 468, 1263, 440, 427, 436, 427, 468, 1263, 444, 423, 440, 427, 440, 423, 468, 423, 
444, 423, 440, 427, 436, 427, 468, 399, 440, 423, 468, 399, 440, 423, 452, 415, 440, 427, 440, 
1291, 440, 1291, 464, 1267, 440, 423, 440, 427, 468, 423, 440, 427, 440, 427, 440, 423, 440, 
427, 440, 423, 440, 427, 440, 1291, 468, 1263, 440, 1291, 468, 395, 444, 423, 440, 427, 440, 
423, 440, 427, 440, 451, 440, 427, 440, 423, 440, 427, 440, 423, 444, 423, 440, 427, 468, 395, 
444, 423, 440, 423, 444, 423, 440, 1291, 440, 427, 440, 423, 468, 1263, 468, 427, 440, 423, 
444, 419, 444, 1291, 440, 423, 468, 399, 440, 423, 444, 423, 440, 427, 440, 423, 444, 423, 
468, 395, 444, 423, 440, 423, 468, 427, 468, 395, 444, 423, 440, 423, 468, 399, 444, 419, 472, 
395, 468, 1263, 440, 1291, 440, 427, 468, 399, 440, 423, 468, 395, 464, 403, 472};

The total is 241469 microseconds or abut 1/4 second of transmit time.

Ah I just realised that I used IRemote to get the TV codes but since the aircon has so many, IRemote didn't capture them all. So I used RemoteIR. It returned INT values which I converted to unsigned.

I just tried getting the TV codes using RemoteIR but I'm having new issues now. The Ir is constantly picking up codes from the surrounds so I can't check the validity of the numbers. Funny enough IRemote semms to be fine at the same time.

Is there a way to increase the number of codes IRemote can collect in one go?

In IRremoteInt.h:

#define RAWBUF  101  // Maximum length of raw duration buffer

I would change that to 500. The buffer is unsigned integers so 500 entries use 1000 bytes of memory. That still leaves 27% of memory free when compiling the IRrecvDumpV2 example for an Arduino UNO so it will probably not crash.

When you make the buffer size greater than 254 you also have to increase the size of the buffer pointer. Change irparams.rawlen, in that same file, from type uint8_t to uint16_t.

The code compiles with some warnings but I think it will probably still work.