Infrared

Overview

I use Infrared signals to:

This is how the whole process looks like:

// https://stackoverflow.com/a/59363959/2115513 digraph SEQ_DIAGRAM { graph [overlap = true, splines = line, nodesep = 1.0, ordering = out]; edge [arrowhead = none]; node [shape = none, width = 0, height = 0, label = ""]; { rank = same; node [shape = rectangle, height = 0.7, width = 2]; homeassistant [label = "Home Assistant"]; cec [label = "ESP device"]; retrotink [label = "Retrotink4K"]; hdmi_switch [label = "HDMI switch"]; } // Draw vertical lines { edge [style = dashed, weight = 6]; homeassistant -> a1 -> a2 -> a3; a3 -> a4 -> a5 -> a6; } { edge [style = dashed, weight = 6]; cec -> b1 b1 -> b2 -> b3 -> b4 [penwidth = 5, style = solid]; b4 -> b5 -> b6; } { edge [style = dashed, weight = 6]; retrotink -> c1; c1 -> c2; c2 -> c3 [penwidth = 5, style = solid, label="switches to profile 1"]; c3 -> c4 -> c5 -> c6; } { edge [style = dashed, weight = 6]; hdmi_switch -> d1 -> d2 -> d3 -> d4; d4 -> d5 [penwidth = 5, style = solid, label="ignores this command"]; d5 -> d6; } { rank = same; a1 -> b1 [label = "send message via ESPhome to device \nEx: 0xB649 0xF40B", arrowhead = normal]; } { rank = same; b2 -> c2 [label = "relay message to Retrotink\nthrough IR on first cable\nEx: 0xB649 0xF40B", arrowhead = normal]; } { rank = same; b4-> c4; c4 -> d4 [label = "relay message to HDMI switch\nthrough IR on second cable\nEx: 0xB649 0xF40B", arrowhead = normal]; } }

This is how the whole setup looks like:

Arduino with raspberry pi

This image: 1. Arduino Nano ESP32-S3 with board. – 2. There’s one cable going to the Retrotink4K and another one going to the HDMI switch.

Note: The reason I used this an Arduino Nano ESP32-S3 over a simpler model is because my CEC through Raspberry PI used an Arduino Nano Every with identical pinout. I could just swap the board and keep the same wiring.

Keypad

This image: an IR LED just above the keypad pointing at the Retrotink4K.

Circuit

I followed adafruit’s “sending ir codes” tutorial to build the circuit.

I used these IR Leds.

ESP Home configuration

I use ESPHome to control the IR LEDs from Home Assistant (“remote_transmitter.transmit_nec” documentation).

I originally captured the IR code myself but all the codes are here: RetroTINK IR Remote Codes

substitutions:
  name: "esphome-retro-ir-nano"
  friendly_name: ESPHome Retro IR Nano

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  name_add_mac_suffix: false
  platformio_options:
    board_build.flash_mode: dio
  project:
    name: esphome.web
    version: '1.0'

esp32:
  board: esp32-s3-devkitc-1
  framework:
    #type: arduino
    type: esp-idf


# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: !secret esphome_encryption_key

# Allow Over-The-Air updates
ota:
  platform: esphome

# Allow provisioning Wi-Fi via serial
improv_serial:

wifi:
  # Set up a wifi access point
  ap: {}

# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:

dashboard_import:
  package_import_url: github://esphome/firmware/esphome-web/esp32s3.yaml@v2
  import_full_config: true

# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.
esp32_improv:
  authorizer: none

# To have a "next url" for improv serial
#web_server:


remote_transmitter:
  pin:
    number: GPIO06
  carrier_duty_percent: 50%


button:
  - platform: template
    name: Switch HDMI_1
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0x1
          command: 0xE41B

  - platform: template
    name: Switch HDMI_2
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0x1
          command: 0xE11E

  - platform: template
    name: Switch HDMI_3
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0x1
          command: 0xF20D

  - platform: template
    name: Switch HDMI_4
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0x1
          command: 0xED12

  - platform: template
    name: Switch HDMI_5
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0x1
          command: 0xEF10

  # https://consolemods.org/wiki/AV:RetroTINK-4K#Remote
  - platform: template
    name: RetroTINK 4k Profile 1
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0xB649
          command: 0xF40B
          repeat:
            times: 2
            wait_time: 100ms

  - platform: template
    name: RetroTINK 4k Profile 2
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0xB649
          command: 0xF807
          repeat:
            times: 2
            wait_time: 100ms

  - platform: template
    name: RetroTINK 4k Profile 3
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0xB649
          command: 0xFC03
          repeat:
            times: 2
            wait_time: 100ms

  - platform: template
    name: RetroTINK 4k Profile 4
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0xB649
          command: 0xF50A
          repeat:
            times: 2
            wait_time: 100ms

  - platform: template
    name: RetroTINK 4k Profile 5
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0xB649
          command: 0xF906
          repeat:
            times: 2
            wait_time: 100ms

  - platform: template
    name: RetroTINK 4k Profile 6
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0xB649
          command: 0xFD02
          repeat:
            times: 2
            wait_time: 100ms

  - platform: template
    name: RetroTINK 4k Profile 7
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0xB649
          command: 0xF609
          repeat:
            times: 2
            wait_time: 100ms

  - platform: template
    name: RetroTINK 4k Profile 8
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0xB649
          command: 0xFA05
          repeat:
            times: 2
            wait_time: 100ms

  - platform: template
    name: RetroTINK 4k Profile 9
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0xB649
          command: 0xFE01
          repeat:
            times: 2
            wait_time: 100ms

  - platform: template
    name: RetroTINK 4k Profile 10
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0xB649
          command: 0xDA25
          repeat:
            times: 2
            wait_time: 100ms

  - platform: template
    name: RetroTINK 4k Profile 11
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0xB649
          command: 0xD926
          repeat:
            times: 2
            wait_time: 100ms

  - platform: template
    name: RetroTINK 4k Profile 12
    on_press:
      - remote_transmitter.transmit_nec:
          address: 0xB649
          command: 0xD827
          repeat:
            times: 2
            wait_time: 100ms

Capturing infrared codes (optional)

I used the circuit described here but I used this old source to capture the codes: MinimalReceiver.ino.