Recording/Decoding IR codes of IR remote using Arduino/ESP8266
To control appliances/devices with Arduino through IR Transmitter it is necessary to know the code of each button of IR remote and its protocol. This is discussed in this Article [[toc]]
Introduction
To control an appliance with Arduino through IR Transmitter, we have to first record IR codes of a remote and which protocol it uses. To do so its rather simple *(You know library makes everything EZ PZ) *. This simple -- Just Connect 3 terminal IR Sensor to Arduino or ESP8266 or NodeMCU
- Upload IR Recorder Code
- Note down code different codes corresponding to different buttons on a remote.
- Also, Note its Protocol.
- Now use that codes to control your favorite (maybe not) appliances.
IR Sensor /Reciever
An IR sensor catches any IR signal or radiation that incident on it, it will give only garbage data.To make it usable, one of the units/IC called "Band pass filter " is attached to it, it groounds / rejects every signal other than 32 kHz(in this article we will be using 38Khz IR Reciever Module). Other things are also connected, like below //ir4 picSo to make an IR receiver module is hard as saving Gotham city from bane (Yes, Bane). So the use of the module is recommended.
Components Required
- Arduino or NodeMCU
- IR Receiver module (Any 38Khz module) , recommended -TSOP382 ,TSOP1738 CHQ1838
Recording IR Codes
Wiring
TSOP382 |
Vcc -- 5V
GND -- GND
Data to pin 11 (Only Arduino, For ESP8266/NodeMCU it can be defined in sketch)
Code
Open Example IRremote -> IRrecvDemo#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
// In case the interrupt driver crashes on setup, give a clue
// to the user what's going on.
Serial.println("Enabling IRin");
irrecv.enableIRIn(); // Start the receiver
Serial.println("Enabled IRin");
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
delay(100);
}
Then open serial monitorNote this data and put in IR Transmitter Sketch.
IR transmitter, Control your TV/ AC etc with Arduino/ESP8266
No comments