Skip to content Skip to sidebar Skip to footer

How to Receive Data IR Remote Sensor 1838B

How to use IR Remote VS1838B or TL1838 Using Arduino

IR Remote Arduino How to Receive Data from VS1838B or TL1838 - Previously I had created an IR Remote TSOP1738 component article made by Vishay.

Today I tried a very cheap infrared receiver, namely VS1838B or TL1838. This component is very much and easy to find. Arduino remote control modules generally use this infrared receiver.

To be able to read infrared data that comes, we first know the protocol used. The protocol simply is the communication language used.

There are 4 most commonly used IR remote protocols namely NEC, SONY, RC5 and RC6 protocols. One infrared recipient or the Remote Control Receiver IR is TSOP1738.
How to Receive Data IR Remote Sensor 1838B
VS1838B Pin Out



VS1838B is one of the IR receivers produced by Shenzhen Lanfeng Technology (LFN). This component has a diode photo and IC embedded in one packaging, so it can be used directly on a microprocessor or microcontroller.


TSOP1738 Features:
  • Epoxy resin package and external protective anti-interference design;
  • Width voltage, 2.7-5.5V;
  • Low power consumption, width and remote angle receipts;
  • Strong anti-interference capabilities, can withstand environmental interference;
  • Output according to TTL, CMOS level, low-level effective level.

Max Value Rating:

  • Supply voltage up to 5.5V
  • Detection distance of up to 15m
  • Supply current up to 1.5mA
  • Output voltage up to 4.5V

Schematics VS1838B Arduino

Now let's make testing against VS1838B IR Remote Arduino. To be able to communicate between VS1838B and Arduino, please connect both as in the following circuit.

How to Receive Data IR Remote Sensor 1838B
VS1838B Arduino Uno


If you are a beginner and feel not familiar with the series above, you can try the IR receiver module that has been sold in the market.

C. IR Remote Library 

After the Arduino Remote IR series is finished, please download the Library for Arduino Ir. This library will make it easier for us to convert signals received by photo detectors into hexadecimal data.


After that, including the library that has been downloaded by:
  • Open Arduino IDE
  • Click Sketch -> Include Library -> Add .zip library
  • Point and select the library that you have downloaded
  • Then click OK.

In this library there have been basic commandments that are very useful in coding processing. Here are the commands.

Command to Receive:
  • IRrecv irrecv(receivePin)
    Create a recipient object, use the name of your choice.

  • irrecv.enableIRIn()
    Start the receipt process. This will activate the timer interruption that consumes a small number of CPUs every 50 μs.

  • irrecv.decode(&results)
    Try to accept the IR code. Returns the correct value if the code has been received, or it is wrong if no one is received. When the code is received, information is saved into "Results".
    results.decode_type: Will be one of the following: NEC, SONY, RC5, RC6, or Unknown.
    results.value: Actual IR code (0 if the type is unknown)
    results.bits: The number of bits used by this code
    results.rawbuf: An array of time IR pulse
    results.rawlen: The number of items stored in the array

  • irrecv.resume()
    After receiving, this must be called to reset the recipient and prepare it to receive another code.

  • irrecv.blink13(true)
    Activate the LED blink when during reception. Because you cannot see infrared light, winking LEDs can be useful when solving problems, or just to provide visual feedback.

Perintah Untuk Pengirim:
  • IRsend irsend;
    Create transmission objects. The pin number is always used, depending on which timer is used by the library.

  • irsend.sendNEC(IRcode, numBits);
    Send code in NEC format.

  • irsend.sendSony(IRcode, numBits);
    Send code in SONY format.

  • irsend.sendRC5(IRcode, numBits);
    Send code in RC5 format.

  • irsend.sendRC6(IRcode, numBits);
    Send code in RC6 format.

  • irsend.sendRaw(rawbuf, rawlen, frequency);
    Send raw code. Usually you will get rawbuf and rawlen content using the receiver many times and evenly the results.

    Some adjustments may be needed for the best performance. The frequency is the frequency of the bandpass filter expected at the recipient, where 38 is the most commonly used.

D. Progam VS1838B Arduino

1. The basic program receives Remote IR data

Well ... after we enter the library, we will see the basic program of data receipts. Here is the basic program. Please upload it to Arduino.

Progam:

#include <IRremote.h>
const int RECV_PIN = 2; //Tentukan pin 2 sebagai input dari VS1838B
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
//Mulai aktifkan protokol IR
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results)) {
//Menampilkan data pada seria monitor
Serial.println(results.value, HEX);
// Menerima data selanjutnya
irrecv.resume();
}
}

After upload is complete, open the Arduino idea monitor series. Make sure the baudrate is selected at the value of 9600 (the bottom right of the series of the monitor).

Now navigate and press one of the remote. So in the series the monitor will display the address with the hexadecimal value.


2. See the type of remote IR protocol

Now, we will try to see the protocol used by your remote. As explained above, there are 4 IR remote protocols used namely NEC, SONY, RC5 and RC6.

The program below will read the type of protocol on the remote you are using, then it will be displayed on the series of the monitor. Please upload the following program.

Program:

#include <IRremote.h>
const int RECV_PIN = 2; //Tentukan pin 2 sebagai input dari VS1838B
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); //Mulai aktifkan protokol IR
irrecv.blink13(true); //Hidupkan LED internal jika ada data masuk
}
void loop() {
if (irrecv.decode(&results)) {
if (results.decode_type == NEC) {
Serial.print("Protokol NEC: ");
} else if (results.decode_type == SONY) {
Serial.print("Protokol SONY: ");
} else if (results.decode_type == RC5) {
Serial.print("Protokol RC5: ");
} else if (results.decode_type == RC6) {
Serial.print("Protokol RC6: ");
} else if (results.decode_type == UNKNOWN) {
Serial.print("Protokol tidak diketahui: ");
}
Serial.println(results.value, HEX);
irrecv.resume(); // Menerima data selanjutnya
}
}

After upload is complete, please press the button on the remote and navigate to the IR Remote Arduino VS1838B. You will see the type of protocol you are using on the monitor series.


3. Turn on the RGB LED using the remote

After you understand the two programs above, we will try to turn on 3 LEDs using the remote.

To turn on 3 red green and blue LEDs we need three buttons. Let's say we have determined 3 hex addresses for remote:

  • Hex 0xFF30cf for red
  • Hex 0xFF18e7 for green
  • Hex 0xFF7A85 for blue

For the circuit, please connect the red LED to pin 12, green LED on PIN 11, and the blue LED on PIN 10. Don't forget to use the resistor 330r.

Please upload the following program on your Arduino. Please press the 1, 2, or 3 remote button.

Program:

#include <IRremote.h>
const int RECV_PIN = 2; //Tentukan pin 2 sebagai input dari VS1838B
int ledMerah = 12;
int ledHijau = 11;
int ledBiru = 10;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); //Mulai aktifkan protokol IR
irrecv.blink13(true); //Hidupkan LED internal jika ada data masuk
pinMode(ledMerah, OUTPUT);
pinMode(ledHijau, OUTPUT); pinMode(ledBiru, OUTPUT);
}
void loop() {
//Data hex 0xFF30CF untuk warna merah
//Data hex 0xFF18E7 untuk warna hijau
//Data hex 0xFF7A85 untuk warna biru
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
if (results.value == 0xFF30CF)
{
digitalWrite(ledMerah, HIGH);
digitalWrite(ledHijau, LOW);
digitalWrite(ledBiru, LOW);
}
if (results.value == 0xFF18E7)
{
digitalWrite(ledMerah, LOW);
digitalWrite(ledHijau, HIGH);
digitalWrite(ledBiru, LOW);
}
if (results.value == 0xFF7A85)
{
digitalWrite(ledMerah, LOW);
digitalWrite(ledHijau, LOW);
digitalWrite(ledBiru, HIGH);
}
irrecv.resume(); // Menerima data selanjutnya
}
}


E. VS1838B Datasheet

For more details about VS1838b, you can see the VS1838B datasheet below.

Thank you for visiting the Chip Piko website. May be useful.

Sumber: www.pjrc.com

Post a Comment for "How to Receive Data IR Remote Sensor 1838B "