README.md
1| Supported Targets | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 |
2| ----------------- | ----- | -------- | -------- | -------- |
3# IR Protocol Example
4
5(See the README.md file in the upper level 'examples' directory for more information about examples.)
6
7This example illustrates how to encode and decode RMT signals with/to common IR protocols (e.g. NEC and RC5).
8
9[NEC](https://www.sbprojects.net/knowledge/ir/nec.php) and [RC5](https://www.sbprojects.net/knowledge/ir/rc5.php) have different encoding rules, but both can be compatible to RMT data format.
10
11The example supports building and parsing both normal and extended NEC/RC5 protocol. And also supports `repeat code` which would be sent out if one remote key got pressed for a specific long time.
12
13## How to Use Example
14
15### Hardware Required
16
17* A development board with supported SoC mentioned in the above `Supported Targets` table
18* An USB cable for power supply and programming
19* A 5mm infrared LED (e.g. IR333C) used to transmit encoded IR signals
20* An infrared receiver module (e.g. IRM-3638T), which integrates a demodulator and AGC circuit.
21
22Example connection :
23
24| ESP chip | IR333C | IRM-3638T |
25| --------------------------- | ------ | --------- |
26| CONFIG_EXAMPLE_RMT_TX_GPIO | Tx | × |
27| CONFIG_EXAMPLE_RMT_RX_GPIO | × | Rx |
28| VCC 5V | √ | × |
29| VCC 3.3V | × | √ |
30| GND | GND | GND |
31
32
33### Configure the Project
34
35Open the project configuration menu (`idf.py menuconfig`).
36
37In the `Example Configuration` menu:
38
39* Select the infrared protocol used in the example under `Infrared Protocol` option.
40* Set the GPIO number used for transmitting the IR signal under `RMT TX GPIO` option.
41* Set the GPIO number used for receiving the demodulated IR signal under `RMT RX GPIO` option.
42* Set the RMT TX channel number under `RMT TX Channel Number` option.
43* Set the RMT RX channel number under `RMT RX Channel Number` option.
44
45### Build and Flash
46
47Run `idf.py -p PORT flash monitor` to build, flash and monitor the project.
48
49(To exit the serial monitor, type ``Ctrl-]``.)
50
51See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.
52
53## Example Output
54
55Run this example, you will see the following output log (for NEC protocol):
56```
57I (2000) example: Send command 0x20 to address 0x10
58I (2070) example: Scan Code --- addr: 0x0010 cmd: 0x0020
59I (2220) example: Scan Code (repeat) --- addr: 0x0010 cmd: 0x0020
60I (4240) example: Send command 0x21 to address 0x10
61I (4310) example: Scan Code --- addr: 0x0010 cmd: 0x0021
62I (4460) example: Scan Code (repeat) --- addr: 0x0010 cmd: 0x0021
63I (6480) example: Send command 0x22 to address 0x10
64I (6550) example: Scan Code --- addr: 0x0010 cmd: 0x0022
65I (6700) example: Scan Code (repeat) --- addr: 0x0010 cmd: 0x0022
66I (8720) example: Send command 0x23 to address 0x10
67I (8790) example: Scan Code --- addr: 0x0010 cmd: 0x0023
68I (8940) example: Scan Code (repeat) --- addr: 0x0010 cmd: 0x0023
69I (10960) example: Send command 0x24 to address 0x10
70I (11030) example: Scan Code --- addr: 0x0010 cmd: 0x0024
71I (11180) example: Scan Code (repeat) --- addr: 0x0010 cmd: 0x0024
72```
73
74## Troubleshooting
75
76For any technical queries, please open an [issue] (https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.
77