An IR (Infrared) Receiver module receives signals from an IR remote control (like TV remotes) and decodes them. It typically uses modulated IR light at 38 kHz.
The most common IR receiver is the VS1838B or HS0038, and it comes in modules with 3 pins:
OUT (Signal)
GND
VCC (usually 3.3V–5V)
The remote control sends IR light pulses in a specific pattern.
The IR receiver demodulates the 38 kHz signal and gives digital output (HIGH/LOW).
The ESP32 reads this pattern and decodes it into a code (usually hexadecimal).
| IR Receiver Pin | Connect to ESP32 |
|---|---|
| OUT | Any GPIO (e.g., GPIO18) |
| VCC | 3.3V or 5V (Check module specs) |
| GND | GND |
ESP32 Dev Board
IR Receiver Module (VS1838 or similar)
IR Remote (any remote like TV, DVD, etc.)
Jumper Wires
Arduino IDE
๐ 6. Required Library
Install the DIYables_IRcontroller library:
Open Arduino IDE
Go to → Tools → Manage Libraries
Search for: DIYables_IRcontroller
Click Install
๐ ๏ธ 10. Common Issues & Fixes
Problem Fix No signal detected Wrong GPIO or poor VCC/GND connection Always same code Remote not compatible or low battery Codes change frequently Use resultToHexidecimal(&results)only
๐ฎ 11. Projects Using IR Receiver
IR Remote-controlled lights
Home automation (TV remote → fan, light, etc.)
IR controlled car or robot
Media player navigation
IR smart switch
Educational quiz buzzer system
๐ 12. Advanced Use Cases
Control multiple devices (e.g., fan, speaker, lights)
Build an IR signal logger
Create a universal remote decoder
Combine with DFPlayer Mini for a remote-controlled audio player
HOW TO OPERATE
#include <DIYables_IRcontroller.h> // DIYables_IRcontroller library#define IR_RECEIVER_PIN 18 // The Arduino pin connected to IR controller
DIYables_IRcontroller_21 irController(IR_RECEIVER_PIN, 200); // debounce time is 200ms
void setup() {Serial.begin(9600);irController.begin();}
void loop() {Key21 command = irController.getKey();if (command != Key21::NONE) {switch (command) {case Key21::KEY_CH_MINUS:Serial.println("CH-");// TODO: YOUR CONTROLbreak;
case Key21::KEY_CH:Serial.println("CH");// TODO: YOUR CONTROLbreak;
case Key21::KEY_CH_PLUS:Serial.println("CH+");// TODO: YOUR CONTROLbreak;
case Key21::KEY_PREV:Serial.println("<<");// TODO: YOUR CONTROLbreak;
case Key21::KEY_NEXT:Serial.println(">>");// TODO: YOUR CONTROLbreak;
case Key21::KEY_PLAY_PAUSE:Serial.println(">||");// TODO: YOUR CONTROLbreak;
case Key21::KEY_VOL_MINUS:Serial.println("-");// TODO: YOUR CONTROLbreak;
case Key21::KEY_VOL_PLUS:Serial.println("+");// TODO: YOUR CONTROLbreak;
case Key21::KEY_EQ:Serial.println("EQ");// TODO: YOUR CONTROLbreak;
case Key21::KEY_100_PLUS:Serial.println("100+");// TODO: YOUR CONTROLbreak;
case Key21::KEY_200_PLUS:Serial.println("200+");// TODO: YOUR CONTROLbreak;
case Key21::KEY_0:Serial.println("0");// TODO: YOUR CONTROLbreak;
case Key21::KEY_1:Serial.println("1");// TODO: YOUR CONTROLbreak;
case Key21::KEY_2:Serial.println("2");// TODO: YOUR CONTROLbreak;
case Key21::KEY_3:Serial.println("3");// TODO: YOUR CONTROLbreak;
case Key21::KEY_4:Serial.println("4");// TODO: YOUR CONTROLbreak;
case Key21::KEY_5:Serial.println("5");// TODO: YOUR CONTROLbreak;
case Key21::KEY_6:Serial.println("6");// TODO: YOUR CONTROLbreak;
case Key21::KEY_7:Serial.println("7");// TODO: YOUR CONTROLbreak;
case Key21::KEY_8:Serial.println("8");// TODO: YOUR CONTROLbreak;
case Key21::KEY_9:Serial.println("9");// TODO: YOUR CONTROLbreak;
default:Serial.println("WARNING: undefined command:");break;}}}