Build Your Own ESP8266 Infrared Smart Controller

If you’d prefer to watch the full video, please click below!


Have you ever wanted to turn your old infrared-controlled devices — like your TV, stereo, or air conditioner — into something smart?

In this tutorial, I’ll show you exactly how to build an ESP8266-based infrared controller that can both receive signals from your existing remote and transmit them back to control your devices.

By the end, you’ll have a fully functional smart IR hub that integrates seamlessly with Home Assistant or Alexa, and stays perfectly in sync with your original remote.

What You’ll Need

Let’s start with the hardware components and why each one matters.

Core Components

  • ESP8266 D1 Mini – The brain of the project. Small, cheap, and easily programmable via ESPHome.
  • Infrared Receiver (VS1838B) – Captures signals from your remote control.
  • Infrared LED Transmitter – Sends infrared commands to your devices.
  • NPN Transistor (e.g., 2N2222) – Acts as an amplifier switch to drive the IR LED with enough current.
  • 100 Ω Resistor – Limits current to the IR LED.
  • 1 kΩ Resistor – Used for the transistor’s base input.
  • 5 V Power Supply – Powers both the ESP8266 and the IR LED.
  • PCB or Breadboard – For assembling the circuit.

You can optionally 3D print a simple enclosure to house everything neatly. (I used a compact case from Thingiverse that fits the D1 Mini and PCB perfectly.)

Circuit Wiring

Here’s a breakdown of how everything connects. (You can also refer to the wiring diagram below.)

Wiring Diagram

Infrared Receiver (VS1838B)

Pin Connection
1 (Left) 5 V (from ESP8266)
2 (Middle) GND
3 (Right) D3 (GPIO0)

Infrared Transmitter (IR LED)

Pin Connection
Anode (long leg) 5 V via 100 Ω resistor
Cathode (short leg) Collector of NPN transistor

NPN Transistor (e.g., 2N2222)

Pin Connection
Collector (C) To IR LED cathode
Base (B) To 1 kΩ resistor → D8 (GPIO15)
Emitter (E) GND

This transistor setup is crucial: the ESP8266’s GPIO pins can’t drive the IR LED directly. The transistor works as a switch, using a small control signal from the ESP8266 to handle a larger current from the 5 V line.

ESPHome Configuration

Now that our hardware is ready, let’s set up the ESPHome firmware to handle both receiving and sending IR signals.

Below is a simplified version of the key parts of the YAML configuration:

esphome:
  name: ir_controller
  platform: ESP8266
  board: d1_mini

globals:
  - id: radio_state
    type: bool
    restore_value: yes
    initial_value: "false"

remote_receiver:
  pin: D3
  dump: nec
  on_nec:
    - address: 0xEF00
      command: 0xF00F
      then:
        - lambda: |-
            id(radio_state) = !id(radio_state);
            ESP_LOGI("main", "Radio state: %s", id(radio_state) ? "ON" : "OFF");

remote_transmitter:
  pin: D8
  carrier_duty_percent: 50%

binary_sensor:
  - platform: template
    name: "Radio Power"
    lambda: |-
      return id(radio_state);

How It Works

  • globals keeps track of the device’s state (on/off), even after a restart.
  • remote_receiver listens for IR codes from your existing remote.
  • remote_transmitter sends the appropriate IR signals to your devices.
  • binary_sensor exposes the current radio state to Home Assistant.

This ensures that your ESP8266 always knows whether your device is actually on or off, even if you use the original remote.

Integrating with Home Assistant

Once flashed, ESPHome will automatically expose entities to Home Assistant. You can then create:

  • On/Off buttons for your device.
  • Automations (e.g., “Turn on stereo when I get home”).
  • Scenes combining multiple infrared-controlled devices.

Each button can send different NEC codes — for example:

  • Power Toggle
  • Volume Up / Down
  • Source Select
  • Mute

You can add as many as you need by following the same pattern.

Testing It Out

To verify everything works:

  1. Open the ESPHome logs.
  2. Press buttons on your original remote — you should see the NEC address and command codes appear.
  3. In Home Assistant, toggle your new controls.
  4. Use a Flipper Zero, smartphone, or another IR learning tool to confirm that your ESP8266 sends the correct signal.

Once both receiving and transmitting work, congratulations — you’ve built a fully functional infrared smart hub!

Wrapping Up

You now have a complete ESP8266 infrared smart controller that:

  • Receives commands from your old remotes
  • Sends IR codes to your devices
  • Integrates with Home Assistant and Alexa
  • Keeps your devices’ states in perfect sync

This is an excellent starter project for anyone diving into ESPHome or DIY home automation.

If you enjoyed this guide, be sure to share this article, or subscribe on YouTube for more ESPHome and DIY Smart Projects. Got questions or ideas? Drop them in the comments — I’d love to help out.

Resources