An ESP-IDF component for Physical Computing
Purpose
Receive and transmit remote control IR signals for ESP32 systems.
How it is done
This repository contains an ESP-IDF component for an IR transmitter and receiver using different remote control protocols. It runs on any ESP32 processor connected to an IR receiver and/or IR transmitter and is built using the ESP-IDF build system in version 5.5+.
Currently two protocols are implemented:
- NEC protocol (used eg. by YAMAHA audio receiver)
- PANASONIC protocol (used eg. by PANASONIC VIERA TV)
The component is implemented as C++ class RmtIr.
Where to find it
rmt_ir is published on the ESP Registry at https://components.espressif.com/components/elrebo-de/rmt_ir.
The source code can be found at https://github.com/elrebo-de/esp_rmt_ir.
How to use it
As an ESP-IDF component rmt_ir must be included into idf_component.yml as a dependency. As usual this can be done by executing this command:
idf.py add-dependency "elrebo-de/rmt_ir^1.2.1"
You need to include rmt_ir.hpp.
Then you have to initialize the RmtIr class:
/* Initialize RmtIr class */
RmtIr* rmtIr = &rmtIr->getInstance(); // get the Singleton instance
rmtIr->setGpioPins(12,26); // set the GPIO pins
rmtIr->initialize(); // initialize RMT IR
Now you can transmit NEC IR codes with transmitNecCommandFrame and transmitNecRepeatFrame and PANASONIC IR codes with transmitPanasonicCommandFrame.
This example sends the IR code for pushing the “TV Scene” button on the remote control of a YAMAHA audio receiver:
rmtIr->transmitNecCommandFrame((uint8_t)0x7a, (uint8_t)0x03); // "TV Scene"
This example sends the IR code for pushing the “Power 0/1” button on the remote control of a PANASONIC VIERA TV:
rmtIr->transmitPanasonicCommandFrame(0x4004, 0x01, 0x00, 0xbc); // "Power 0/1"
It is also possible to receive IR signals with an IR receiver.
This example receives IR signals in an endless loop and prints the received data in the log:
while(1) {
rmtIr->receiveNecOrPanasonicFrame();
}

Leave a Reply