IR

Overview

Working with IR receiver and transmitters in ESPHome.

Note

This page only covers the receiver so far.

IR receiver

Using a TSOP38238 IR receiver diode.

  
Datasheet for TSOP38238tsop382.pdf / tsop382.adafruit.pdf
Adafruit infosheetadafruit-ir-sensor.pdf1

Specifications

NameSymbolValue
Supply voltage to
Supply current to (max )
Output voltage to
Output current

Pinout

PinUsage
1OUT
2
3 ()

Diagram

The IR diode works without the resistor and capacitor, but it is recommended to use them for protection against electrostatic overstress.

SymbolValue
-

ESPHome config

Set up a remote_receiver component, these settings work well for me with a TSOP38238 diode2:

remote_receiver:
  id: recv_ir
  pin:
    number: ${receiver_pin}
    inverted: true
    mode:
      input: true
      # Enable the internal pullup if you dont have any external pullup
      # resistors in the circuit and are getting unreliable readings
      pullup: false
  # Decode and dump thse remot protocols/codecs to the logger
  # on log_level INFO
  dump: "all"

  # Percentage that the remote signal lengths can deviate in the
  # decoding process
  tolerance: "50%"
  # Filter pusles shorter than this
  filter: 250us
  # How long a signal shold remain stable (not change) to be considered
  # complete
  idle: 4ms

  # Default for ESP32
  buffer_size: "10kb"

  # only on ESP32
  memory_blocks: 3
  on_rc_switch: {}

Watch the log output, point an IR remote in the vague direction of the IR diode and press some buttons. The keycodes get dumped into the log and you can set up binary_sensor components or automations for them3.

The remote for my amplifier uses the nec protocol:

binary_sensor:
  - platform: remote_receiver
    id: ir_nad_vol_down
    name: "NAD VOL_DOWN"
    icon: "mdi:volume-minus"
    entity_category: ""
    nec:
      address: "0x7C87"
      command: "0x738C"
    filters:
      - delayed_off: 2s

  - platform: remote_receiver
    id: ir_nad_vol_up
    name: "NAD VOL_UP"
    icon: "mdi:volume-plus"
    entity_category: ""
    nec:
      address: "0x7C87"
      command: "0x7788"
    filters:
      - delayed_off: 2s

Creates two binary_sensor entities that briefly turn true when the keycodes for the volume buttons are emitted and detected.

References

10

IR basic connection - Arduino Stack Exchange: answers explain the difference between a 2-leg photodiode and 3-leg module.

13

ESPHome IR blaster example - Home Assistant forum: Includes C++ code examples with type casting