I'm using RC5 encoding for my project.
I'm sending signals using RC5 Protocol. The transmitter is sending the signals correctly. But on the receiver node, when I decode the signals, Library is unable to identify the protocol. I'm using XIAO RP2040 for transmitter node and ATmega328 nano for receiver node.
The code I'm using is from IRremote Library's examples.
Here's my transmitter setup and code.
#include "PinDefinitionsAndMore.h"
#include <IRremote.hpp> // include the library
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
while (!Serial)
; // Wait for Serial to become available. Is optimized away for some cores.
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
Serial.print(F("Send IR signals at pin "));
Serial.println(IR_SEND_PIN);
/*
* The IR library setup. That's all!
*/
IrSender.begin(); // Start with IR_SEND_PIN -which is defined in PinDefinitionsAndMore.h- as send pin and enable feedback LED at default feedback LED pin
disableLEDFeedback(); // Disable feedback LED at default feedback LED pin
}
/*
* Set up the data to be sent.
* For most protocols, the data is build up with a constant 8 (or 16 byte) address
* and a variable 8 bit command.
* There are exceptions like Sony and Denon, which have 5 bit address.
*/
uint8_t sAddress = 0x1F; // example address
uint8_t sCommand = 0x34;
uint8_t sRepeats = 0;
void loop() {
Serial.println(F("Send RC5 with 5 bit address and 6 bit command"));
Serial.flush();
// Send RC5 signal
IrSender.sendRC5(sAddress, sCommand, sRepeats, true);
/*
* Increment send values
*/
sCommand += 0x11;
sRepeats++;
// clip repeats at 4
if (sRepeats > 4) {
sRepeats = 4;
}
delay(1000); // delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal
}
#include <Arduino.h>
#define DECODE_RC5
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
//#define RAW_BUFFER_LENGTH 750 // For air condition remotes it requires 750. Default is 200.
/*
* This include defines the actual pin number for pins like IR_RECEIVE_PIN, IR_SEND_PIN for many different boards and architectures
*/
#include "PinDefinitionsAndMore.h"
#include <IRremote.hpp> // include the library
void setup() {
Serial.begin(115200);
while (!Serial)
; // Wait for Serial to become available. Is optimized away for some cores.
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
// Start the receiver and if not 3. parameter specified, take LED_BUILTIN pin from the internal boards definition as default feedback LED
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
Serial.print(F("Ready to receive IR signals of protocols: "));
printActiveIRProtocols(&Serial);
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
}
void loop() {
if (IrReceiver.decode()) {
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
Serial.println(F("Received noise or an unknown (or not yet enabled) protocol"));
// We have an unknown protocol here, print extended info
IrReceiver.printIRResultRawFormatted(&Serial, true);
IrReceiver.resume(); // Do it here, to preserve raw data for printing with printIRResultRawFormatted()
} else {
Serial.println(F("Received RC5"));
IrReceiver.resume(); // Early enable receiving of the next IR frame
IrReceiver.printIRResultShort(&Serial);
IrReceiver.printIRSendUsage(&Serial);
}
Serial.println();
if (IrReceiver.decodedIRData.command == 0x10) {
// do something
} else if (IrReceiver.decodedIRData.command == 0x11) {
// do something else
}
}
}
I run the code and it always falls in if (IrReceiver.decodedIRData.protocol == UNKNOWN), and after 10-15 pulses it correctly detects the protocol for once or twice before going back to the same behavior.
Can anyone please point me to any possible mistake that I may be making here? The code snippets are from IRremote Library and I'm using them without changing them.
The transmitter is sending the signals correctly.
... how do you know this? \$\endgroup\$