Table of Contents

ESP32 Infrared Remote

Metadata

Introduction

This project extends an existing Home Assistant setup (on Raspberry Pi 4) to control IR‐only devices via an ESP32 acting as an IR transceiver, and to monitor indoor temperature and humidity. We use the YS-IRTM module to sniff and replay NEC‐protocol commands, and a DHT11 sensor to read environment data every 30 minutes. All IR commands and sensor readings are exposed in Home Assistant as entities.

General Description

Block Diagram

Modules and Interactions

Hardware Design

Parts List

Total cost: ≈ 94 RON

Connections and Wiring

Software Design

Environment & Components

Receive Handling

1. YS-IRTM decodes NEC IR and emits 3 bytes over UART.  
2. ESPHome buffers 3 bytes, then publishes an MQTT/state update (`ir_hub/last_command`).  
3. Home Assistant sensor template splits into user-code and command.

Transmit Handling

1. HA invokes `switch.ir_send_<device>_<cmd>`.  
2. ESPHome writes 5-byte payload (Addr: 0xA1, F1: 0xF1, UC High, UC Low, Cmd) to UART.  
3. YS-IRTM emits NEC frame (9 ms mark, 4.5 ms space, data bits 562 µs @38 kHz).  
4. Module replies 0xF1 on success; ESPHome retries once after 1 s if no ack.

Sensor Handling

Known IR Codes

Function NEC Code
Power On/Off 01 FE 04
Mute 01 FE 09
Volume Down 01 FE 05
Volume Up 01 FE 06

Images

Images

Hardware setup: ESP32, YS-IRTM module and DHT11 sensor wired on the breadboard and powered on. ESP32 in Home Assistant UI: The ESP32 entity and exposed IR switches and sensor values displayed on the HA dashboard. Inside Temperature Graph: Logged DHT11 readings showing temperature variations over time. Inside Humidity Graph: Logged DHT11 readings showing humidity fluctuations over time.

Results

All NEC remotes in the stereo system are learned and replayed via Home Assistant. Indoor temperature and humidity are logged every 30 minutes and available in HA dashboards. OTA updates allow wireless firmware management.

Future Improvements (Brief)

Download

Download PDF