Reputation: 13
I have a soundbar that is not supported by my fireTV stick, so to avoid having to use multiple remotes every time, I'm trying to use an Arduino Uno to "translate" the signal from my fireTV remote to my soundbar's protocol (and maybe add some other things later).
Right now I have an IR receiver, an IR LED and a button. The receiver triggers an interrupt and prints the received data, when the button is pressed the LED starts to send a predefined IR signal. In theory, it all works fine. I'm sending the same data as the original remote control (at least according to my IR receiver), but the device does nothing.
Heres my Code:
#include <IRremote.h>
const int RECV_PIN = 2;
const int SEND_PIN = 5;
const int BUTTON_PIN = 3;
IRrecv irrecv(RECV_PIN);
IRsend irsend(SEND_PIN);
IRRawDataType receivedData;
decode_type_t receivedProtocol;
uint16_t receivedAddress;
uint16_t receivedCommand;
irparams_struct *rawData;
int rawDataBits;
//bool dataReceived = false;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start IR reception
attachInterrupt(digitalPinToInterrupt(RECV_PIN), irIsr, CHANGE); // Add interrupt
pinMode(BUTTON_PIN, INPUT); // Set button pin as input
}
void loop()
{
if (digitalRead(BUTTON_PIN) == HIGH)
{
Serial.println("Button pressed");
// SEND
uint16_t sAddress = 0x0102;
uint8_t sCommand = 72;
uint8_t sRepeats = 0;
irsend.sendNEC(sAddress & 0xFF, sCommand, sRepeats);
// irsend.sendRC5(sAddress & 0xFF, sCommand, sRepeats); //tried the same for a different remote, didnt work
//dataReceived = false;
delay(500); // Debounce delay
}
}
void irIsr()
{
if (irrecv.decode())
{
// When an IR signal is received
rawData = irrecv.decodedIRData.rawDataPtr;
rawDataBits = irrecv.decodedIRData.numberOfBits;
receivedData = irrecv.decodedIRData.decodedRawData;
receivedProtocol = irrecv.decodedIRData.protocol;
receivedAddress = irrecv.decodedIRData.address;
receivedCommand = irrecv.decodedIRData.command;
Serial.println("Protocol: " + String(receivedProtocol) +
", Address: " + String(receivedAddress) +
", Command: " + String(receivedCommand) +
", Raw Data: " + String(receivedData));
// Print Raw Data for debugging purposes
Serial.print( "RawDataBits: "+ rawDataBits);
Serial.print("\n Raw Data: ");
for (int i = 0; i < rawDataBits; i++)
{
Serial.print(rawData->rawbuf[i]); // Access the rawbuf-Array in irparams_struct
Serial.print(" ");
}
Serial.println();
//dataReceived = true;
irrecv.resume(); // Continue reception for the next signal
}
}
This is the Output from the original remote:
Protocol: 8, Address: 2, Command: 72, Data: 3075013890
Raw Data: 13365 164 90 12 10 14 32 13 9 13 10 12 11 11 11 12 11 11 11 13 32 12 11 11 34 12 33 13 33 11 34 11
This is the Output when I press the Button:
Button pressed
Protocol: 8, Address: 2, Command: 72, Data: 3075013890
Raw Data: 12208 164 88 11 11 12 33 12 11 11 11 12 11 12 11 11 11 12 11 12 33 11 11 12 33 11 34 11 34 11 34 11
It looks to me like I'm sending the right data, but maybe there's more to it than I think?
One thing I thought of is that the remote could be using some sort of proprietary protocol that is misidentified as NEC, could that be my problem?
I would be very grateful if anyone has any ideas.
Upvotes: 1
Views: 101