This is an old revision of the document!
ESP32 Infrared Remote
Author: Petru Zincenco
Master: IA
Introduction
I am creating this project because I already have a Home Assistant server running on a Raspberry Pi 3, and I want to extend its capabilities to control my stereo system and air conditioner via IR. By turning an ESP32 into an IR transceiver, I can sniff existing NEC-protocol remote commands, replay them, and even send arbitrary data over IR directly from my phone through Home Assistant.
General Description
Block Diagram
Modules and Interactions
Hardware Design
Parts List
Schematics and Signal Diagrams
Connections and Wiring Diagram
Software Design
Development Environment and Libraries
ESPHome (YAML-based configuration, OTA updates, Home Assistant integration)
`uart` component on TX/RX pins at 9600 baud to interface with the YS-IRTM’s TTL serial
`text_sensor` (custom lambda) for buffering and parsing incoming 3-byte payloads into HA events
`remote_transmitter` declared (IR modulation offloaded to module’s 38 kHz carrier engine)
Implemented Algorithms and Structures
Receive Handling
YS-IRTM demodulates 38 kHz IR, decodes NEC frames internally, then emits three data bytes (User Code High, User Code Low, Command) over UART upon each valid command
ESPHome listens on UART, accumulates up to three bytes in a small buffer, then fires an MQTT/state update and resets the buffer
NEC repeat frames are suppressed by the module; ESPHome can apply further debouncing or grouping if needed
Transmit Handling
To transmit, ESP32 sends a five-byte payload via `uart.write`:
Address byte (default `0xA1`)
Command byte `F1` (`0xF1`, trigger TX)
Data byte 1 (NEC User Code High)
Data byte 2 (NEC User Code Low)
Data byte 3 (NEC Command)
The module appends the inverse of the command byte automatically and generates a full NEC frame with a 9 ms leading mark, 4.5 ms space, 562 µs mark/space per bit, and final mark at 38 kHz
On success, YS-IRTM replies over UART with the command byte (`0xF1`); silence indicates a bad payload
ESPHome waits (e.g. 1000 ms) for the ack and can retry transmission if no response arrives
Results
Conclusions
Download
Journal
Bibliography/Resources