ESP8266 NodeMCU -Controling IR Remote Control Infrared Receiver VS1838B

Infrared communication is a common, inexpensive, and easy to use wireless communication technology. IR light is very similar to visible light, except that it has a slightlty longer wavelength. This means IR is undetectable to the human eye.
In this tutorial we will learn how to use a infrared remote controler to control 2 LEDs, via a infrared receiver VS1838B. It is very easy to use this remote controler and is full of bottons and capabilities. Use this tutorial to control systems inside your house. Lets start.

Parts Required

  • VS1838B Infrared Receiver and Remote Controler;
  • Breadboard (optional);
  • 2 x LED;
  • 2 x 220 ohm resistor;
  • Male to male jumper wires (optional);

The VS1838B

Figure 1

Infra-Red light is actually normal light with a particular colour. We need to konw there are many more sources of Infra-Red light. The sun is the brightest source of all, but there are many others, like: light bulbs, candles, central heating system, and even our body radiates Infra-Red light.

The VS1838B is a infrared receiver for infrared remote control systems, suitable for infrared communications or remote control applications where high receiver sensitivity and ambient light rejection is required.
It comprises of a PIN diode, a preamplifier and other signal conditioning circuitry integrated in the package. This makes the device easily
interfaced with a Microcontroller.

The VS1838B IR receiver is a standard IR remote control receiver series with excellent suppression of disturbance signals, with low power consumption and an easy to use package. It mates well with embedded electronics and can be used with common IR remotes. The VS1838B features can be seen below:

  • Built-in Filter at 38KHz;
  • Compatible with Arduino, Raspberry Pi;
  • Working Voltage: 2.7 – 5.5V DC;
  • Receiver Distance: 22 – 25m.

A common modulation scheme for IR communication is something called 38kHz modulation. There are very few natural sources that have the regularity of a 38kHz signal, so an IR transmitter sending data at that frequency would stand out among the ambient IR. The 38kHz modulated IR data is the most common, but other frequencies can be used.

When you hit a key on your remote, the transmitting IR LED will blink very quickly for a fraction of a second, transmitting encoded data to VS1838B. If you were to hook an oscilloscope up to your TV remote’s IR LED, you would see a signal similar to the first graph in the figure 2.

Figure 2

This modulated signal is exactly what the VS1838B sees. However, the objective of the receiving device is to demodulate the signal and output a binary waveform that can be read by a microcontroller. When you read the OUT pin of the VS1838B with the wave from above, you will see something like the second graph. This is pretty much what you need to know about the sensor.


Figure 3

Follow the figure above and start connecting the hardware to the board. Connect the green LED to pin D3 and LED the yelow LED to pin D4 with a 220 ohm resistor. After that, connect the VS1838B signal pin to D1 and next the power pins. In this point everything is connected.

Instaling Libraries For VS1838B

In order to install the required library for the board to decode the signals, go to Sketch > Include Library > Manage Libraries… and then search for “IRremoteESP8266”. Click on the entry shown in figure 4 and then select Install.

Figure 4


Notice that in the begining of the sketch, is a number of include libraries. Remember that you should follow the steps above to correctely instal all the libraries. The libraries (IRrecv.h and IRutils.h) are included in the IRremoteESP8266.h, that was instaled above.

Copy the main sketch bellow to your Arduino IDE project and save it. Heve fun!!


Leave a Reply

Your email address will not be published. Required fields are marked *