IR Remote Decoder Using Arduino Nano

by Electroveins in Circuits > Arduino

1616 Views, 16 Favorites, 0 Comments

IR Remote Decoder Using Arduino Nano

thumb.jpg

A small decoder which can decode the NEC protocol signals from your TV remote in Hexadecimal form. A small project with proper library/ code

Supplies

mini_20220911_123255.jpg
mini_20220911_123147.jpg

Components used:

1) TSOP1738

2) Arduino NANO

3) SSD1306 0.96” display

4) 5V power supply

5) Custom PCB

Story:

mini_20220911_123024.jpg
My Video2.gif

I made some projects using IR sensors and NEC protocol. Still, I don’t have a cool interface to decode the remote data. Most of the basic IR remote work on NEC protocol which used 32-bit value. NEC protocol has 8-bit address, 8 bit inverse of address, 8-bit data and its inverse. To decode this data, we only need a very few parts with a microcontroller. This decoded data is used in other projects like IR remote control car, DIY light remote, fan remote and to make a universal remote-control system.

I will convert the circuit into a PCB prototype shield. So that it is easy to decode the data whenever required. Just plug your microcontroller, sensor and battery. And I am using JLCPCB PCB prototype service for a long time. Honestly speaking it is the best reliable service offering 5PCBs in just $2 and 10 for $5. For this we need an Infrared Receiver sensor, here I am using TSOP1738 for these reasons.

TSOP1738 Receiver:

sr.png

The TSOP17.. – series are miniaturized receivers for infrared remote-control systems. PIN diode and preamplifier are assembled on lead frame, the epoxy package is designed as IR filter. The demodulated output signal can directly be decoded by a microprocessor. TSOP17.. is the standard IR remote control receiver series, supporting all major transmission codes. Get the more information from the datasheet.

  • Photo detector and preamplifier in one package
  • Internal filter for PCM frequency
  • Improved shielding against electrical field disturbance
  • Output active low
  • Low power consumption (3.3 to 5.5volts @ 10mA)
  • High immunity against ambient light
  • Continuous data transmission possible (1200 bit/s)

And don’t get confuse in the pin description of the TSOP series. You can follow the above given picture for better understanding. Pins of different packages are not the same but do the same job.

Circuit Diagram:

CIRCUIT.png
mini_20220908_125610.jpg

The circuit is designed with small I2C OLED screen. 4 wire interface minimized the wiring and overall schematics. SCL and SDA is connected to A5 and A4 of Arduino respectively. TSOP1738 has 3 pins, 2 for the power input and one for data output. And Output data from the sensor is in the digital form so we can use Arduino in digital read mode and there are some specific libraries which can convert/ decode the data into respective HEX and decimal form.

To reduce the efforts, you can use the PCB prototype shield made by me. The project is very easy but there are very less chances of working without proper libraries data.

PCB Designs:

fdg.png

I made the shield so that you can plug the microcontroller after programming then the IR receiver sensor and display. And we are ready to after powering the system. No need of any external components. Even this project can be made without screen, serial monitor window inside Arduino IDE can do the same job.

Download the Gerber files from here and upload them to JLCPCB, Sign-up using this link to get $54 coupons and place your order just in $2 for 5 PCB boards.

Code:

/* hello guys here I am using older versions on IR library so please download and install all the previous version
* The link to download preferred library is:
* This code is made by Sagar Saini/ YouTube: Sagar networks
* Any questions or queries DM me on Instagram Saini_sagar_7294.
* Explore my website for more interesting projects: www.circuitkicker.com
*/

#include <IRremote.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET 1
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);
const int RECV_PIN=10;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
irrecv.blink13(true); // Led will blink on receiving each signal
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // try 0x3D also if OLED is not working
display.clearDisplay();
}

void loop() {
if (IrReceiver.decode())
{
Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX); // decoding method accoriding to the new libraries
display.clearDisplay();
display.setTextSize(2); // Set the text size
display.setTextColor(WHITE);
display.setCursor(1,10);
display.print("IR DECODER");
display.setCursor(10,40);
display.print(IrReceiver.decodedIRData.decodedRawData, HEX);
display.display();
irrecv.resume(); // Receive the next value
delay(500);
}
}

Libraries Used:

mini_20220912_125027.jpg

I used IR remote library 3.0.1 version for the decoding of NEC in Hexadecimal form. You can download the same library with IR decoding Arduino sketch from here. This code is not universal, this one need some special old IRremote libraries. There are other protocols also which are used by companies like Sony, LG and TOSHIBA which are mentioned in the library read me file.

Working:

My Video.gif
My Video1.gif

The OLED screen reset function is not working well so initially it would not show any data. But when the remote button is pressed for the data decoding it initialize with the code and display the correct value. These values are in the decoded Hexadecimal form. We are not using RAW data values because it will mess up the whole code.

I got the best results form this project and in future I will made a universal IR remote which can receive the data from other remote and per key is programmable. And with the touch of IoT it can make the home automation easier.