Part

Infrared receiver, VS1838B

It inverts, and that is the whole of it: OUT idles high and drops while a burst arrives.

See every part
  • 4 pins
  • In 4 projects
  • In 2 lessons
Drawn live by the editor's own code, at the size you see it.
At a glance

The Infrared receiver, VS1838B in brief

What it is, and where it sits on the bench.

The VS1838B is the black infrared receiver with a domed lens that comes bagged with the kit remote: a photodiode, an amplifier tuned to 38 kHz, a filter and a demodulator in one three-legged package. Its pins are OUT, GND and VCC, at 2.7 to 5.5 V, so it runs from 5 V on an Uno with OUT on any digital pin (the IRremote examples use 11), and from 3.3 V on an ESP32 with OUT on any GPIO. Mokxi adds a fourth pin, IR, the light: wire it to the handset’s IR pin, or leave it unwired and any IR LED or handset pointed at the lens within range reaches it. The model inverts as the real one does: OUT idles high through an internal 30 k pull-up and goes low while a burst arrives, so the NEC leader reads as 9 ms of LOW, and a 38 kHz carrier wired straight to IR is demodulated. Below 2.7 V, OUT floats. The classic mistake is decoding with the polarity upside down; another is an unpowered receiver, which reads exactly like an idle one. Ambient light, signal strength and the automatic gain control are not modeled.

Family
Clocks and links
Pins
4
Pins

4 pins

Named as the editor names them, so a wire lands where you expect it.

Output1

  • OUT

Input or output2

  • GND
  • VCC

Input1

  • IR
How to use it

How to use the VS1838B IR receiver with an Arduino

Facing the lens, the legs are OUT, GND and VCC. Here OUT goes to pin 11, GND to GND and VCC to 5 V; the receiver needs no resistor, because OUT has its own pull-up of about 30 k. The extra IR pin on Mokxi’s part is the light: in this circuit it is wired to the handset, and left unwired it takes any remote or IR LED pointed at the lens.

The receiver inverts. OUT idles HIGH and goes LOW while a 38 kHz burst arrives, so the NEC leader shows up as 9 ms of LOW; the dome on the part lights while the line is down. The IRremote library handles that for you: IrReceiver.begin(11) starts timer 2 sampling the pin in the background, decode() turns true once a frame is in, and resume() readies it for the next. Timer 2 then belongs to the library, so tone() and analogWrite() on pins 3 and 11 stop working, as on a real Uno.

Part pin
Board pin
OUT
Pin 11
GND
GND
VCC
5 V
IR
The remote’s IR pin (the beam)

The VS1838B runs from 2.7 to 5.5 V, so on an ESP32 power it from 3.3 V and OUT can go to any GPIO.

Arduino Uno: IR decoderlive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
The receive loop, from the IR decoder sketch
#define DECODE_NEC
#include <IRremote.hpp>

void setup() {
  Serial.begin(9600);
  IrReceiver.begin(11, ENABLE_LED_FEEDBACK);
}

void loop() {
  if (IrReceiver.decode()) {
    Serial.println(IrReceiver.decodedIRData.command, HEX);
    IrReceiver.resume();
  }
}
How it is modeled

What is true about the Infrared receiver, VS1838B, here

In its help article’s own words: what the simulation gets right, and where it stops.

Not modeled

The carrier and the air, as above. The automatic gain control, so this receiver never blanks. A real one turns its gain down under a long continuous burst and stops seeing anything, which is why NEC's leader is 9 ms and not 90. The tuning, so a burst at any rate at all is a burst here and two remotes on different carriers would interfere. The few hundred microseconds of edge error a real receiver has, which is what makes a decoder's tolerances necessary; here the edges are exact. And no protocol but NEC: no RC-5, no Sony SIRC, no extended NEC with a 16-bit address.

From Signals you time, not read, in full.

Projects

See the Infrared receiver, VS1838B in a project

4 built-in projects use it. Each opens in the editor, already wired.

Lessons

Where it turns up in a lesson

2 lessons place it in their own circuits.

Boards

The boards it is shown on

Each of these 2 boards has a built-in project with the Infrared receiver, VS1838B in it.

Boards

The Infrared receiver, VS1838B on each board

The pins, the voltage and the code change from board to board. Each page has that board’s wiring and a circuit you can run.

Libraries

Arduino libraries for the Infrared receiver, VS1838B

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

Wire up the Infrared receiver, VS1838B

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.