This is an old revision of the document!


ESP32 Infrared Remote Hub (Finished)

Metadata

  • Author: Petru Zincenco
  • Master: IA
  • Date Completed: 21 May 2025

Overview

This project delivers a universal infrared (IR) transceiver based on an ESP32, seamlessly integrated with Home Assistant via ESPHome. The hub can learn and replay any remote protocol—whether NEC, extended‐NEC, or raw pulse sequences—allowing full control of air conditioners, audio systems, and other IR-controlled devices. All IR commands are exposed in Home Assistant as switches and buttons, enabling automation, voice control, and OTA updates without additional hardware beyond the ESP32 and simple IR receiver/emitter components.

System Architecture

Block Diagram

Modules and Interactions

  • Home Assistant Server (Raspberry Pi 3)
    1. Hosts ESPHome in Docker for firmware builds, API management, and OTA updates.
    2. Manages ESP32 IR Hub over Wi-Fi (static IP) using the native ESPHome integration.
    3. Presents learned IR commands as Home Assistant entities (switches/buttons).
  • ESP32 IR Hub
    1. Runs custom ESPHome firmware configured in YAML.
    2. Interfaces with a “dumb” IR demodulator (e.g. TSOP38238) for raw pulse capture.
    3. Drives an IR LED (via transistor) for signal replay, at 38 kHz carrier.
    4. Communicates with Home Assistant via the ESPHome native API for real-time control and OTA.
  • IR Receiver/Emitter Hardware
    1. TSOP38238/4838 demodulator for full pulse timing and protocol learning.
    2. IR LED with driver transistor for reliable transmission of any learned code.

Hardware Implementation

Parts List

  • ESP32 development board
  • TSOP38×38 IR demodulator
  • IR LED + transistor + resistor for emitter driver
  • 4-channel 3.3 V ↔ 5 V level shifter (for optional serial devices)
  • Jumper wires and breadboard or PCB

Total cost: ≈ 85 RON

Connections and Wiring

  • IR Receiver (TSOP) → ESP32 GPIO (e.g. 23)
  • IR LED Anode → 5 V through current-limiting resistor → transistor → ESP32 GPIO (e.g. 22) for carrier enable
  • Transistor Base → ESP32 GPIO through base resistor
  • GND/common for ESP32, TSOP, and emitter driver
  • (Optional) UART RX/TX via level shifter if using serial modules

Design Rationale

  • Switched from YS-IRTM module to TSOP demodulator to capture raw pulses and support proprietary protocols (e.g. Yamato AC).
  • On-board IR LED driver ensures full carrier strength and reliable distance.
  • Level shifter retained for future expansions requiring TTL serial devices.

Firmware and Software

Development Environment

  • ESPHome in Docker: Containerized with host-network mode, USB mapping (`/dev/ttyUSB0`), and OTA port (3232) exposed.
  • YAML-First Configuration: Single `ir_hub.yaml` defines Wi-Fi, static IP (`192.168.0.136`), API, OTA, logger, UART (if needed), and switch entities.
  • Static IP Assignment: Ensures reliable discovery and OTA, bypassing mDNS issues in Docker.

IR Signal Handling

  • Learning (Capture)
    1. The TSOP38×38 demodulator outputs clean digital bursts.
    2. ESPHome’s `remote_receiver` component timestamps each pulse/space.
    3. A custom lambda buffers pulses into arrays, then exposes them via an MQTT/state event or as a Home Assistant sensor for inspection.
  • Replaying (Transmit)
    1. ESPHome’s `remote_transmitter` component drives the IR LED at 38 kHz.
    2. Learned pulse arrays are stored in flash (as `raw_codes`), then replayed on command via a Home Assistant switch.
    3. Automatic retries and acknowledgments ensure reliable transmission.

Home Assistant Integration

  • Entity Exposure: Each learned code appears as a `switch.<device>_<command>` in Home Assistant.
  • OTA Updates: After initial USB flash, firmware updates are pushed over-the-air from the ESPHome container.
  • Dashboard Controls: Custom Lovelace cards allow “Learn”, “Replay”, and “Delete” actions per IR code.

Results

  • Universal IR Hub: Successfully captures and replays NEC, extended protocols, and custom raw timings.
  • Seamless HA Control: All IR actions are directly automatable and available for voice assistants.
  • Robust OTA Workflow: New features and learned codes can be deployed wirelessly without on-site USB access.

Conclusions

By leveraging a simple TSOP demodulator, ESPHome’s flexible firmware, and Home Assistant’s automation capabilities, this ESP32-based hub becomes a truly universal IR bridge. It not only replicates existing remotes but can learn new ones on-the-fly, integrate with smart home automations, and evolve through OTA updates.

Download

Bibliography/Resources

  • ESPHome Documentation – Getting Started, UART, Remote Receiver/Transmitter
  • Home Assistant – ESPHome Integration Guide
  • TSOP38×38 Datasheet – Vishay
iothings/proiecte/2025sric/esp32-ir-hub.1747782725.txt.gz · Last modified: 2025/05/21 02:12 by petru.zincenco
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0