Hello everyone,
I'm currently working on a project where I have to control two air conditioner units from different vendors via IR. I have the original remotes and I'm trying to "clone" them to send the same codes/signals to control the AC. I was able to read these codes with an IR receiver so far (at least I guess so, I got consistent data so I'm assuming it's correct), but I'm having troubles to send it using an IR emitter module.
I've tried different libraries, tried to use their examples and I also tried some solutions from many posts from the forum and other pages, but I haven't got any luck making this work.
The library I'm currently using is IRremote v4.4.1 included in the Arduino IDE (GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols). I've followed the instructions and was able to read the signal sent from the original remote. But I can't make it work when sending it back to the unit.
I'm trying to read data from two different remotes when pressing the POWER ON button using the following code based on the library's examples:
#define RAW_BUFFER_LENGTH 750
#include <Arduino.h>
#include <IRremote.hpp>
#define IR_RECEIVE_PIN 2
void setup() {
Serial.begin(9600);
Serial.println("Starting");
IrReceiver.begin(IR_RECEIVE_PIN, false);
}
void loop() {
if(IrReceiver.decode()){
Serial.println("received ir");
Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);
IrReceiver.printIRResultShort(&Serial);
IrReceiver.printIRSendUsage(&Serial);
Serial.println();
IrReceiver.resume();
}
}
Remote "A" sends a single code (36897D58) with an UNKNOWN protocol. I've checked with different buttons and the received codes seem to be consistent.
received ir
36897D58
Protocol=UNKNOWN Hash=0x36897D58 100 bits (incl. gap and start) received
Remote "B" sends two codes (6500 and 4900) with PulseDistance protocol.
I've also checked with different buttons, and with this remote it seems to send two codes in a row: first the same 6500 no matter which button I press, then the second other code according to the button/function - in this case 4900=power on. (I needed to comment out the printIRSendUsage line for the second code to be read, otherwise it only read the first same 6500 for every button I pressed).
WIth printIRSendUsage:
received ir
6500
Protocol=PulseDistance Raw-Data=0x6500 112 bits LSB first
Send on a 8 bit platform with:
uint32_t tRawData[]={0x226CB23, 0x4000, 0x0, 0x6500};
IrSender.sendPulseDistanceWidthFromArray(38, 3050, 1550, 550, 1050, 550, 250, &tRawData[0], 112, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
WIthout printIRSendUsage:
6500
Protocol=PulseDistance Raw-Data=0x6500 112 bits LSB first
received ir
4900
Protocol=PulseDistance Repeat gap=71000us Raw-Data=0x4900 112 bits LSB first
For the second remote I tried to used the command it gave on the output, and I also tried with raw data for the two remotes. In both cases the signal is sent by the IR LED (I don't know whether it's sent correctly or not), but it doesn't do anything with the AC devices.
I've also tried many other approaches, none of them successful, including:
- Using the ReceiveDump example from the library to get raw data and then send using with
IrSender.sendRaw(rawData,RAW_DATA_ARRAY_SIZE,38)
- Same thing as above but reading the data with the solution proposed on this post #9: [SOLVED] Sending IR-Code with ATTINY85 ? (iremote library) - #8 by AnalysIR
- Air Conditioner Record long Infrared Remote control signals - Arduino
- I also tried with other libraries, for instance IRRemoteControl and IRLib2 (GitHub - cyborg5/IRLib2: Library for receiving, decoding, and sending infrared signals using Arduino).
- Many many other examples which didn't seem to work
Data read from the original remotes using the ReceiveDump example from the library:
Remote A: (in this case it only reads the first code/part of the code - 0x6500 for any button, the 0x4900 part is not read)
Protocol=PulseDistance Raw-Data=0x6500 112 bits LSB first
Send on a 8 bit platform with:
uint32_t tRawData[]={0x226CB23, 0x4000, 0x0, 0x6500};
IrSender.sendPulseDistanceWidthFromArray(38, 3050, 1550, 550, 1050, 550, 250, &tRawData[0], 112, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
Raw result in internal ticks (50 us) - with leading gap
rawData[228]:
-65535
+61,-31
+11,-21 +10,-21 +10,- 6 +10,- 6
+11,- 5 +11,-21 +10,- 6 +10,- 6
+10,-22 +10,-21 +10,- 6 +10,-21
+11,- 5 +11,- 6 +10,-21 +10,-21
+11,- 5 +11,-21 +10,-21 +10,- 5
+11,- 6 +11,-21 +10,- 6 +10,- 5
+11,- 5 +12,-21 +10,- 5 +11,- 6
+10,- 6 +10,- 5 +12,- 4 +12,- 5
+11,- 5 +11,- 5 +11,- 5 +11,- 6
+11,- 5 +11,- 5 +11,- 5 +11,- 5
+11,- 5 +12,- 4 +12,- 6 +10,- 5
+11,- 5 +11,- 6 +10,-22 +10,- 5
+11,- 5 +11,- 5 +11,- 5 +11,- 5
+12,- 4 +12,- 5 +11,- 5 +11,- 5
+11,- 5 +12,- 4 +12,- 5 +11,- 5
+11,- 5 +11,- 5 +11,- 5 +12,- 4
+12,- 5 +11,- 5 +11,- 5 +11,- 5
+12,- 4 +12,- 4 +12,- 5 +11,- 5
+11,- 5 +11,- 5 +12,- 4 +12,- 5
+11,- 5 +11,- 5 +11,- 5 +11,- 5
+12,- 4 +12,- 5 +11,- 5 +11,- 5
+11,- 5 +12,- 4 +12,- 5 +11,- 5
+11,- 5 +11,- 6 +10,- 5 +12,- 4
+12,- 5 +11,- 5 +11,- 5 +11,- 5
+11,- 5 +12,- 4 +12,- 5 +11,- 5
+11,- 5 +11,- 6 +11,- 4 +12,- 5
+11,-21 +10,- 5 +11,-22 +10,- 5
+11,- 5 +11,-21 +10,-22 +10,- 5
+11
Sum: 2172
Raw result in microseconds - with leading gap
rawData[228]:
-3276750
+3050,-1550
+ 550,-1050 + 500,-1050 + 500,- 300 + 500,- 300
+ 550,- 250 + 550,-1050 + 500,- 300 + 500,- 300
+ 500,-1100 + 500,-1050 + 500,- 300 + 500,-1050
+ 550,- 250 + 550,- 300 + 500,-1050 + 500,-1050
+ 550,- 250 + 550,-1050 + 500,-1050 + 500,- 250
+ 550,- 300 + 550,-1050 + 500,- 300 + 500,- 250
+ 550,- 250 + 600,-1050 + 500,- 250 + 550,- 300
+ 500,- 300 + 500,- 250 + 600,- 200 + 600,- 250
+ 550,- 250 + 550,- 250 + 550,- 250 + 550,- 300
+ 550,- 250 + 550,- 250 + 550,- 250 + 550,- 250
+ 550,- 250 + 600,- 200 + 600,- 300 + 500,- 250
+ 550,- 250 + 550,- 300 + 500,-1100 + 500,- 250
+ 550,- 250 + 550,- 250 + 550,- 250 + 550,- 250
+ 600,- 200 + 600,- 250 + 550,- 250 + 550,- 250
+ 550,- 250 + 600,- 200 + 600,- 250 + 550,- 250
+ 550,- 250 + 550,- 250 + 550,- 250 + 600,- 200
+ 600,- 250 + 550,- 250 + 550,- 250 + 550,- 250
+ 600,- 200 + 600,- 200 + 600,- 250 + 550,- 250
+ 550,- 250 + 550,- 250 + 600,- 200 + 600,- 250
+ 550,- 250 + 550,- 250 + 550,- 250 + 550,- 250
+ 600,- 200 + 600,- 250 + 550,- 250 + 550,- 250
+ 550,- 250 + 600,- 200 + 600,- 250 + 550,- 250
+ 550,- 250 + 550,- 300 + 500,- 250 + 600,- 200
+ 600,- 250 + 550,- 250 + 550,- 250 + 550,- 250
+ 550,- 250 + 600,- 200 + 600,- 250 + 550,- 250
+ 550,- 250 + 550,- 300 + 550,- 200 + 600,- 250
+ 550,-1050 + 500,- 250 + 550,-1100 + 500,- 250
+ 550,- 250 + 550,-1050 + 500,-1100 + 500,- 250
+ 550
Sum: 108600
Result as internal 8bit ticks (50 us) array - compensated with MARK_EXCESS_MICROS=20
uint8_t rawTicks[227] = {61,31, 11,21, 10,21, 10,6, 10,6, 11,5, 11,21, 10,6, 10,6, 10,22, 10,21, 10,6, 10,21, 11,5, 11,6, 10,21, 10,21, 11,5, 11,21, 10,21, 10,5, 11,6, 11,21, 10,6, 10,5, 11,5, 12,21, 10,5, 11,6, 10,6, 10,5, 12,4, 12,5, 11,5, 11,5, 11,5, 11,6, 11,5, 11,5, 11,5, 11,5, 11,5, 12,4, 12,6, 10,5, 11,5, 11,6, 10,22, 10,5, 11,5, 11,5, 11,5, 11,5, 12,4, 12,5, 11,5, 11,5, 11,5, 12,4, 12,5, 11,5, 11,5, 11,5, 11,5, 12,4, 12,5, 11,5, 11,5, 11,5, 12,4, 12,4, 12,5, 11,5, 11,5, 11,5, 12,4, 12,5, 11,5, 11,5, 11,5, 11,5, 12,4, 12,5, 11,5, 11,5, 11,5, 12,4, 12,5, 11,5, 11,5, 11,6, 10,5, 12,4, 12,5, 11,5, 11,5, 11,5, 11,5, 12,4, 12,5, 11,5, 11,5, 11,6, 11,4, 12,5, 11,21, 10,5, 11,22, 10,5, 11,5, 11,21, 10,22, 10,5, 11}; // Protocol=PulseDistance Raw-Data=0x6500 112 bits LSB first
Result as microseconds array - compensated with MARK_EXCESS_MICROS=20
uint16_t rawData[227] = {3030,1570, 530,1070, 480,1070, 480,320, 480,320, 530,270, 530,1070, 480,320, 480,320, 480,1120, 480,1070, 480,320, 480,1070, 530,270, 530,320, 480,1070, 480,1070, 530,270, 530,1070, 480,1070, 480,270, 530,320, 530,1070, 480,320, 480,270, 530,270, 580,1070, 480,270, 530,320, 480,320, 480,270, 580,220, 580,270, 530,270, 530,270, 530,270, 530,320, 530,270, 530,270, 530,270, 530,270, 530,270, 580,220, 580,320, 480,270, 530,270, 530,320, 480,1120, 480,270, 530,270, 530,270, 530,270, 530,270, 580,220, 580,270, 530,270, 530,270, 530,270, 580,220, 580,270, 530,270, 530,270, 530,270, 530,270, 580,220, 580,270, 530,270, 530,270, 530,270, 580,220, 580,220, 580,270, 530,270, 530,270, 530,270, 580,220, 580,270, 530,270, 530,270, 530,270, 530,270, 580,220, 580,270, 530,270, 530,270, 530,270, 580,220, 580,270, 530,270, 530,270, 530,320, 480,270, 580,220, 580,270, 530,270, 530,270, 530,270, 530,270, 580,220, 580,270, 530,270, 530,270, 530,320, 530,220, 580,270, 530,1070, 480,270, 530,1120, 480,270, 530,270, 530,1070, 480,1120, 480,270, 530}; // Protocol=PulseDistance Raw-Data=0x6500 112 bits LSB first
uint16_t address = 0x0;
uint16_t command = 0x0;
uint32_t rawData = 0x6500;
Pronto Hex as string
char prontoData[] = "0000 006D 0072 0000 0076 003B 0016 0028 0014 0028 0014 000B 0014 000B 0016 0009 0016 0028 0014 000B 0014 000B 0014 002A 0014 0028 0014 000B 0014 0028 0016 0009 0016 000B 0014 0028 0014 0028 0016 0009 0016 0028 0014 0028 0014 0009 0016 000B 0016 0028 0014 000B 0014 0009 0016 0009 0018 0028 0014 0009 0016 000B 0014 000B 0014 0009 0018 0007 0018 0009 0016 0009 0016 0009 0016 0009 0016 000B 0016 0009 0016 0009 0016 0009 0016 0009 0016 0009 0018 0007 0018 000B 0014 0009 0016 0009 0016 000B 0014 002A 0014 0009 0016 0009 0016 0009 0016 0009 0016 0009 0018 0007 0018 0009 0016 0009 0016 0009 0016 0009 0018 0007 0018 0009 0016 0009 0016 0009 0016 0009 0016 0009 0018 0007 0018 0009 0016 0009 0016 0009 0016 0009 0018 0007 0018 0007 0018 0009 0016 0009 0016 0009 0016 0009 0018 0007 0018 0009 0016 0009 0016 0009 0016 0009 0016 0009 0018 0007 0018 0009 0016 0009 0016 0009 0016 0009 0018 0007 0018 0009 0016 0009 0016 0009 0016 000B 0014 0009 0018 0007 0018 0009 0016 0009 0016 0009 0016 0009 0016 0009 0018 0007 0018 0009 0016 0009 0016 0009 0016 000B 0016 0007 0018 0009 0016 0028 0014 0009 0016 002A 0014 0009 0016 0009 0016 0028 0014 002A 0014 0009 0016 06C3 ";
Remote B:
Protocol=UNKNOWN Hash=0x36897D58 100 bits (incl. gap and start) received
Received noise or an unknown (or not yet enabled) protocol
Raw result in internal ticks (50 us) - with leading gap
rawData[200]:
-65535
+87,-85
+11,-32 +11,-11 +10,-32 +11,-31
+11,-11 +11,-10 +11,-31 +11,-12
+10,-12 + 9,-32 +11,-10 +11,-11
+11,-31 +11,-32 +11,-10 +11,-32
+11,-10 +11,-11 +10,-12 +10,-31
+11,-32 +11,-32 +10,-32 +11,-32
+11,-31 +11,-32 +11,-31 +11,-11
+11,-11 +10,-11 +10,-11 +11,-11
+10,-11 +11,-31 +11,-11 +11,-31
+11,-32 +11,-11 +10,-12 + 9,-11
+11,-32 +10,-11 +11,-32 +10,-11
+11,-10 +11,-32 +11,-31 +11,-32
+10,-103 +86,-85 +11,-32 +11,-11
+10,-32 +11,-32 +10,-11 +11,-10
+11,-32 +11,-10 +11,-11 +11,-31
+11,-11 +11,-11 +10,-32 +10,-32
+11,-11 +10,-32 +11,-11 +10,-12
+10,-10 +11,-32 +11,-31 +11,-32
+11,-32 +10,-32 +11,-32 +11,-31
+11,-32 +11,-10 +11,-11 +11,-10
+11,-10 +11,-11 +11,-10 +11,-32
+11,-10 +11,-32 +11,-31 +11,-12
+10,-11 +10,-11 +10,-32 +11,-11
+10,-32 +11,-11 +10,-12 +10,-31
+11,-32 +11,-32 + 9
Sum: 3536
Raw result in microseconds - with leading gap
rawData[200]:
-3276750
+4350,-4250
+ 550,-1600 + 550,- 550 + 500,-1600 + 550,-1550
+ 550,- 550 + 550,- 500 + 550,-1550 + 550,- 600
+ 500,- 600 + 450,-1600 + 550,- 500 + 550,- 550
+ 550,-1550 + 550,-1600 + 550,- 500 + 550,-1600
+ 550,- 500 + 550,- 550 + 500,- 600 + 500,-1550
+ 550,-1600 + 550,-1600 + 500,-1600 + 550,-1600
+ 550,-1550 + 550,-1600 + 550,-1550 + 550,- 550
+ 550,- 550 + 500,- 550 + 500,- 550 + 550,- 550
+ 500,- 550 + 550,-1550 + 550,- 550 + 550,-1550
+ 550,-1600 + 550,- 550 + 500,- 600 + 450,- 550
+ 550,-1600 + 500,- 550 + 550,-1600 + 500,- 550
+ 550,- 500 + 550,-1600 + 550,-1550 + 550,-1600
+ 500,-5150 +4300,-4250 + 550,-1600 + 550,- 550
+ 500,-1600 + 550,-1600 + 500,- 550 + 550,- 500
+ 550,-1600 + 550,- 500 + 550,- 550 + 550,-1550
+ 550,- 550 + 550,- 550 + 500,-1600 + 500,-1600
+ 550,- 550 + 500,-1600 + 550,- 550 + 500,- 600
+ 500,- 500 + 550,-1600 + 550,-1550 + 550,-1600
+ 550,-1600 + 500,-1600 + 550,-1600 + 550,-1550
+ 550,-1600 + 550,- 500 + 550,- 550 + 550,- 500
+ 550,- 500 + 550,- 550 + 550,- 500 + 550,-1600
+ 550,- 500 + 550,-1600 + 550,-1550 + 550,- 600
+ 500,- 550 + 500,- 550 + 500,-1600 + 550,- 550
+ 500,-1600 + 550,- 550 + 500,- 600 + 500,-1550
+ 550,-1600 + 550,-1600 + 450
Sum: 176800
Result as internal 8bit ticks (50 us) array - compensated with MARK_EXCESS_MICROS=20
uint8_t rawTicks[199] = {87,85, 11,32, 11,11, 10,32, 11,31, 11,11, 11,10, 11,31, 11,12, 10,12, 9,32, 11,10, 11,11, 11,31, 11,32, 11,10, 11,32, 11,10, 11,11, 10,12, 10,31, 11,32, 11,32, 10,32, 11,32, 11,31, 11,32, 11,31, 11,11, 11,11, 10,11, 10,11, 11,11, 10,11, 11,31, 11,11, 11,31, 11,32, 11,11, 10,12, 9,11, 11,32, 10,11, 11,32, 10,11, 11,10, 11,32, 11,31, 11,32, 10,103, 86,85, 11,32, 11,11, 10,32, 11,32, 10,11, 11,10, 11,32, 11,10, 11,11, 11,31, 11,11, 11,11, 10,32, 10,32, 11,11, 10,32, 11,11, 10,12, 10,10, 11,32, 11,31, 11,32, 11,32, 10,32, 11,32, 11,31, 11,32, 11,10, 11,11, 11,10, 11,10, 11,11, 11,10, 11,32, 11,10, 11,32, 11,31, 11,12, 10,11, 10,11, 10,32, 11,11, 10,32, 11,11, 10,12, 10,31, 11,32, 11,32, 9}; // Protocol=UNKNOWN Hash=0x36897D58 100 bits (incl. gap and start) received
Result as microseconds array - compensated with MARK_EXCESS_MICROS=20
uint16_t rawData[199] = {4330,4270, 530,1620, 530,570, 480,1620, 530,1570, 530,570, 530,520, 530,1570, 530,620, 480,620, 430,1620, 530,520, 530,570, 530,1570, 530,1620, 530,520, 530,1620, 530,520, 530,570, 480,620, 480,1570, 530,1620, 530,1620, 480,1620, 530,1620, 530,1570, 530,1620, 530,1570, 530,570, 530,570, 480,570, 480,570, 530,570, 480,570, 530,1570, 530,570, 530,1570, 530,1620, 530,570, 480,620, 430,570, 530,1620, 480,570, 530,1620, 480,570, 530,520, 530,1620, 530,1570, 530,1620, 480,5170, 4280,4270, 530,1620, 530,570, 480,1620, 530,1620, 480,570, 530,520, 530,1620, 530,520, 530,570, 530,1570, 530,570, 530,570, 480,1620, 480,1620, 530,570, 480,1620, 530,570, 480,620, 480,520, 530,1620, 530,1570, 530,1620, 530,1620, 480,1620, 530,1620, 530,1570, 530,1620, 530,520, 530,570, 530,520, 530,520, 530,570, 530,520, 530,1620, 530,520, 530,1620, 530,1570, 530,620, 480,570, 480,570, 480,1620, 530,570, 480,1620, 530,570, 480,620, 480,1570, 530,1620, 530,1620, 430}; // Protocol=UNKNOWN Hash=0x36897D58 100 bits (incl. gap and start) received
Pronto Hex as string
char prontoData[] = "0000 006D 0064 0000 00A8 00A3 0016 003D 0016 0014 0014 003D 0016 003B 0016 0014 0016 0012 0016 003B 0016 0016 0014 0016 0012 003D 0016 0012 0016 0014 0016 003B 0016 003D 0016 0012 0016 003D 0016 0012 0016 0014 0014 0016 0014 003B 0016 003D 0016 003D 0014 003D 0016 003D 0016 003B 0016 003D 0016 003B 0016 0014 0016 0014 0014 0014 0014 0014 0016 0014 0014 0014 0016 003B 0016 0014 0016 003B 0016 003D 0016 0014 0014 0016 0012 0014 0016 003D 0014 0014 0016 003D 0014 0014 0016 0012 0016 003D 0016 003B 0016 003D 0014 00C5 00A6 00A3 0016 003D 0016 0014 0014 003D 0016 003D 0014 0014 0016 0012 0016 003D 0016 0012 0016 0014 0016 003B 0016 0014 0016 0014 0014 003D 0014 003D 0016 0014 0014 003D 0016 0014 0014 0016 0014 0012 0016 003D 0016 003B 0016 003D 0016 003D 0014 003D 0016 003D 0016 003B 0016 003D 0016 0012 0016 0014 0016 0012 0016 0012 0016 0014 0016 0012 0016 003D 0016 0012 0016 003D 0016 003B 0016 0016 0014 0014 0014 0014 0014 003D 0016 0014 0014 003D 0016 0014 0014 0016 0014 003B 0016 003D 0016 003D 0012 06C3 ";
Some points to consider:
- The hardware is working fine. I tested this same setup with the IRremote library controlling a Sony TV using the native Sony protocol from the library, reading with the same ReceiveDemo example and sending in my code with
IrSender.sendSony(0x1, 0x12, 3, 12);
(volume up) and it worked. - I can confirme it is possible to "clone" the remotes I'm trying to and actually make them work because I have a proprietary universal remote device that does that (and it doesn't care about any protocol, encoding or whatever, it just asks to press the button on the remote and clones it, and it works with both the remotes I'm trying to clone with Arduino).
So I seem to be able to read the data from the original remotes but can't make it work when sending. I don't know if the problem is actually when sending it, or if I'm reading it wrong. I read several topics here and in other forums where people seemed to have a similar problem and some of them got it working, but they didn't say exactly how, or their solution didn't work for me.
Has anyone else gotten through this who can give me some direction on what to do to get this to work? I don't know what else to try. Any help is appreciated
P.S. I'm currently testing with an Arduino Nano ATmega328P