How to Build an Arduino-IRremote-Style Multi-Protocol IR Library for ESP-IDF?
Posted: Fri Jun 20, 2025 5:54 am
Hi all,
I’m working on an ESP32-C6 project using ESP-IDF, and I’d like to build an IR remote library similar in functionality and flexibility to the Arduino-IRremote library.
My goals are:
Protocol auto-detection: Detect and decode multiple IR protocols (RC5, NEC, Sony, etc.) from IR receiver input.
Robust decoding: Extract address, command, toggle, and other relevant fields, and handle noisy or truncated signals gracefully.
Logging for reusing: protocol name, address, command, toggle, and raw timing data for unknown or unsupported protocols.
Encoding/transmitting: Generate and emit IR signals for the supported protocols.
API: Provide a clean API for decode, resume, and send operations, similar to Arduino-IRremote’s IrReceiver and IrSender objects.
I’m already using the RMT peripheral for IR signal capture and transmission.
I have successfully handled the protocol detection for multiple currently NEC, RC5, RC6, and Samsung protocols and decoding the NEC and encoding and transmitting the NEC protocol. As a next step, I have started to decode the RC5; it is hard.
I’ve noticed that Arduino-IRremote is very tolerant of imperfect signals and handles protocol detection and decoding very robustly—even when the frame is a bit short or noisy. I’d like to achieve the same reliability and ease of use in ESP-IDF.
Questions:
I’m working on an ESP32-C6 project using ESP-IDF, and I’d like to build an IR remote library similar in functionality and flexibility to the Arduino-IRremote library.
My goals are:
Protocol auto-detection: Detect and decode multiple IR protocols (RC5, NEC, Sony, etc.) from IR receiver input.
Robust decoding: Extract address, command, toggle, and other relevant fields, and handle noisy or truncated signals gracefully.
Logging for reusing: protocol name, address, command, toggle, and raw timing data for unknown or unsupported protocols.
Encoding/transmitting: Generate and emit IR signals for the supported protocols.
API: Provide a clean API for decode, resume, and send operations, similar to Arduino-IRremote’s IrReceiver and IrSender objects.
I’m already using the RMT peripheral for IR signal capture and transmission.
I have successfully handled the protocol detection for multiple currently NEC, RC5, RC6, and Samsung protocols and decoding the NEC and encoding and transmitting the NEC protocol. As a next step, I have started to decode the RC5; it is hard.
I’ve noticed that Arduino-IRremote is very tolerant of imperfect signals and handles protocol detection and decoding very robustly—even when the frame is a bit short or noisy. I’d like to achieve the same reliability and ease of use in ESP-IDF.
Questions:
- Are there any open-source ESP-IDF libraries that closely mimic Arduino-IRremote’s multi-protocol approach and API?
- What are the key architectural or timing differences I should watch out for when porting or simulating Arduino-IRremote’s logic in ESP-IDF?
- How do you handle protocol detection and robust decoding (e.g., tolerating missing bits, signal inversion, or noise) in your ESP-IDF IR projects?
- Any tips for logging and replaying unknown protocols (raw mode) in ESP-IDF?
- If you have built a similar library or have code samples, I’d appreciate any pointers or references!
- Is the Tx and Rx config capable of all protocols?
Code: Select all
rmt_receive_config_t receive_config = {
.signal_range_min_ns = 1250,
.signal_range_max_ns = 12000000,
};
rmt_rx_channel_config_t rx_channel_cfg = {
.gpio_num = IR_RX_NUM,
.clk_src = RMT_CLK_SRC_DEFAULT,
.resolution_hz = IR_RESOLUTION_HZ,
.mem_block_symbols = 64,
};
rmt_tx_channel_config_t tx_channel_cfg = {
.gpio_num = IR_TX_NUM,
.clk_src = RMT_CLK_SRC_DEFAULT,
.resolution_hz = IR_RESOLUTION_HZ,
.mem_block_symbols = 64,
.trans_queue_depth = 4,
};
rmt_transmit_config_t transmit_config = {
.loop_count = 0, // no loop
};