How to Build an Arduino-IRremote-Style Multi-Protocol IR Library for ESP-IDF?

Dharanesh
Posts: 4
Joined: Thu Mar 28, 2024 5:43 am

How to Build an Arduino-IRremote-Style Multi-Protocol IR Library for ESP-IDF?

Postby Dharanesh » 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:
  • 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
};

nopnop2002
Posts: 362
Joined: Thu Oct 03, 2019 10:52 pm
Contact:

Re: How to Build an Arduino-IRremote-Style Multi-Protocol IR Library for ESP-IDF?

Postby nopnop2002 » Wed Sep 03, 2025 4:07 am

Any tips for logging and replaying unknown protocols (raw mode) in ESP-IDF?
You can send raw symbols.

Code: Select all

// Define your raw RMT symbols (duration and level pairs)
rmt_symbol_word_t your_raw_rmt_symbols[] = {
    {.duration0 = 100, .level0 = 1, .duration1 = 50, .level1 = 0},
    {.duration0 = 200, .level0 = 1, .duration1 = 100, .level1 = 0},
    // ... more symbols
};



rmt_copy_encoder_config_t config = {};
rmt_encoder_handle_t encoder = NULL;
rmt_new_copy_encoder(&config, &encoder);

rmt_transmit_config_t transmit_config = {
        .loop_count = 0, // no loop
};
    
rmt_transmit(tx_channel, encoder, your_raw_rmt_symbols, sizeof(your_raw_rmt_symbols), transmit_config);



Who is online

Users browsing this forum: Google [Bot] and 3 guests