Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

IR receiver (VS1838B) with NodeMCU ESP8266 — wiring and decoder code

Wire a VS1838B IR receiver to a NodeMCU ESP8266 on D5 at 3.3 V and decode any TV or set-top-box remote with IRremote 4.x.

Arduino C++Verified — core esp8266 3.1.2, IRremote 4.7.1, 3 Nov 2026Compile-only

Community draft — report a mistake

An IR receiver turns any old remote into a controller for your NodeMCU — switch a relay, change an LED colour or drive a menu without a phone.

The VS1838B needs just one signal wire. Put OUT on D5, power it from 3V3, and the sketch prints the protocol, address and command of each button so you can copy them into your own project. Keep the receiver off D8: its idle-HIGH output fights the ESP8266’s boot strapping.

Wiring

NodeMCU ESP8266Only the pins used are shown · 3.3 V logicVS1838B IR receiver (38 kHz)GND3V3D5OUTGNDVCC
Every connection
NodeMCU ESP8266VS1838B IR receiver (38 kHz)WireNotes
3V3VCCredAt 3.3 V, OUT never goes above the GPIO limit.
GNDGNDblack
D5OUTyellowGPIO14. OUT idles HIGH and pulses LOW while a signal arrives.

2.7–5.5 V part, 3.3 V board. Power it from your board's logic voltage; OUT is an active-LOW signal at VCC level.

Board quirks

  • The receiver’s output idles HIGH. On D8 (GPIO15) that would stop the NodeMCU booting, because GPIO15 must be LOW at reset. D5, D6, D7, D1 and D2 are safe.
  • IRremote’s LED feedback is disabled in the sketch: the NodeMCU’s on-board LED sits on D4 (GPIO2), a boot pin, and flashing it on every signal is more confusing than useful.
  • For air-conditioner remotes (long frames with temperature and mode), the ESP8266-specific IRremoteESP8266 library decodes far more protocols. IRremote is used here because the same sketch also runs on Uno and ESP32.
  • The VS1838B is tuned to 38 kHz. Fluorescent tubes and direct sunlight can produce junk “Unknown protocol” lines — shade the receiver.

Code

ir-receiver-nodemcu.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// VS1838B IR receiver on a NodeMCU (ESP8266) with IRremote 4.x.
// VCC → 3V3, GND → GND, OUT → D5 (GPIO14).
// Press buttons on any TV / set-top-box remote and note the codes for your own project.
#include <IRremote.hpp>

const uint8_t IR_PIN = D5;  // not D8: the receiver idles HIGH and GPIO15 must be LOW at boot

void setup() {
  Serial.begin(115200);
  Serial.println();
  IrReceiver.begin(IR_PIN, DISABLE_LED_FEEDBACK);  // the on-board LED is on D4, a boot pin — leave it alone
  Serial.println("IR receiver on D5 (GPIO14) - press a remote button");
}

void loop() {
  if (!IrReceiver.decode()) return;
  IRData &d = IrReceiver.decodedIRData;
  if (d.flags & IRDATA_FLAGS_IS_REPEAT) {
    Serial.println("(repeat)");
  } else if (d.protocol == UNKNOWN) {
    Serial.println("Unknown protocol (noise, or an AC remote with long frames)");
  } else {
    Serial.printf("%s  address 0x%04X  command 0x%02X\n", getProtocolString(d.protocol), d.address, d.command);
  }
  IrReceiver.resume();
}

Library: IRremote (Armin Joachimsmeyer (shirriff, z3t0)) — compiled with IRremote 4.7.1.

Expected serial output

Serial Monitor · 115200Output
IR receiver on D5 (GPIO14) - press a remote button
NEC  address 0x0000  command 0x45
(repeat)
NEC  address 0x0000  command 0x46
Unknown protocol (noise, or an AC remote with long frames)

Common errors

Nothing is printed when pressing buttons

Check the pin order of your receiver — bare VS1838B parts and modules differ. Point a phone camera at the remote to confirm it emits.

Board stopped booting after wiring the receiver

OUT is on D8 or D3. Move it to D5. See boot mode (1,6).

↑↓ to move · Enter to open