I have a Pioneer SBX-300 soundbar that has an IR remote. I want to emulate some of the IR signals used by the remote so i can programmatically control the soundbar.
Using the IRRemote library i have created the following code to read the IR signal coming from the remote:
#include <IRremote.h>
IRrecv ir(4);
void setup() {
Serial.begin(115200);
ir.enableIRIn();
}
void loop() {
if (ir.decode()) {
IRData decoded = ir.decodedIRData;
String hex = String(decoded.decodedRawData, HEX);
ir.resume();
if (hex.equals("0")) return; // sometimes blank signals get picked up
Serial.println("Hex code: " + hex);
Serial.println("Address: " + String(decoded.address));
Serial.println("Command: " + String(decoded.command));
Serial.println("Extra: " + String(decoded.extra));
Serial.println("Flags: " + String(decoded.flags));
Serial.println("Protocol: " + String(decoded.protocol));
Serial.println("NumBits: " + String(decoded.numberOfBits));
Serial.println();
}
}
Now when i press for example the power button once i get the following output:
Hex code: 5ea159a6
Address: 166
Command: 161
Extra: 0
Flags: 0
Protocol: 8
NumBits: 32
Hex code: 43bc50af
Address: 175
Command: 188
Extra: 0
Flags: 1
Protocol: 9
NumBits: 32
As you can see, there is 2 different IR signals being sent, each with a different code.
Using a different arduino, i was able to recreate this exact output to the console by using the following code:
#include <IRremote.h>
void setup() {
IrSender.begin(53);
IrSender.enableIROut(38);
}
void loop() {
IrSender.sendNEC(166, 161, 0); //5ea159a6
delay(7); // edit: 7ms seems to be the minimum delay needed or the receiver wont pick up 2 signals
IrSender.sendNEC2(175, 188, 0); //43bc50af
delay(1000);
}
this prints out the exact same result to the console as the remote does, but the soundbar doesnt turn on or off.
My only thought could be that the protocol used by my remote doesnt get picked up correctly by the IRRemote library. I know too little about IR stuff to know if this is the case and how i could go about "reading" and recreating the actual used protocol then.