Approved, not published yet. Visible on the preview site only.

Make any split AC smart with an ESP32 IR blaster

A small Wi-Fi board and an infrared LED give an ordinary split AC schedules, phone control and voice. What to build, how to set it up and what goes wrong.

Automation8 min read

A calm bedroom with a wall-mounted split AC above long curtains

It is Monday morning and the office AC has been running since Friday evening. The remote is in a drawer, the second remote is in someone's bag, and nobody remembers who left last.

Most split ACs in Indian homes and offices have no Wi-Fi. Rather than replace a machine that cools perfectly well, or buy an IR hub tied to a vendor's cloud app, you can use the infrared the AC already understands. A small Wi-Fi board with an infrared LED speaks that language too, and a home automation hub tells it what to say.

We built this for a Midea-made unit on the Coolix protocol and an LG unit. Here is what to build, how to set it up and the mistakes to skip.

Why this works, and when not to bother

A TV remote sends "volume up". An AC remote sends the whole state in every press: power, mode, temperature, fan speed and often swing, packed into one frame of invisible light. A board that builds the same frame can put the AC into any state directly.

Each manufacturer has its own protocol. Coolix is common on Midea-made units and their many rebadges. Two open source libraries cover most of the ground: IRremote (the one we used), which handles common protocols and sends any raw pulse pattern, and IRremoteESP8266, which runs on the ESP32 with a large catalogue of AC protocols. ESPHome has ready-made IR climate components for several brands and is often the fastest route.

When not to do this:

  • Your AC already has Wi-Fi, or the maker sells an add-on module. Use that.
  • You need confirmed state. Infrared is one way. If you must know the compressor is running, you need a power meter as well, or a different approach.
  • You do not want to solder or flash firmware. A ready-made IR hub that works locally with Home Assistant is a reasonable trade.
  • You do not already run Home Assistant. The board is the easy half; an always-on hub is the real commitment. A local IR hub is the honest shortcut if you only want one AC on a schedule.

What you need

Prices are approximate and vary by seller.

  • ESP32 development board, the common 30-pin DevKit type: roughly ₹300 to ₹500. It needs 2.4 GHz Wi-Fi.
  • 5 mm 940 nm infrared LED, the ordinary remote kind: roughly ₹5 to ₹20.
  • NPN transistor to drive the LED, such as an SS8050: a few rupees.
  • Resistors: 220 Ω for the base and about 11 Ω for the LED (we used two 22 Ω in parallel): a few rupees.
  • 38 kHz IR receiver such as the VS1838B, to learn codes and to hear the original remote afterwards: roughly ₹20 to ₹50.
  • Perfboard and a USB power adapter: roughly ₹100 to ₹300.
  • A micro-USB data cable and a laptop with the Arduino IDE or ESPHome (free).
  • A Home Assistant install and an MQTT broker, which we assume you already run.
  • Optional: any room temperature sensor you already have, for the card's current temperature; and a door sensor if you want the "off if a door stays open" automation.

Why the LED needs a transistor

An ESP32 pin supplies a few tens of milliamps at most. An LED driven straight from a pin works close up and fades out across a room.

The transistor acts as a switch: the pin turns it on through the 220 Ω resistor, and it connects the LED to the board's 5 V supply through the 11 Ω resistor. In our build that gives peaks of roughly 330 mA. That is far too much continuously, but a frame lasts around 50 milliseconds and IR LEDs are rated for much higher pulse current; check your datasheet.

The wiring:

  • 5 V (the VIN pin) → LED long leg (anode).
  • LED short leg (cathode) → 11 Ω → transistor collector.
  • Transistor emitter → ground.
  • ESP32 pin → 220 Ω → transistor base.
  • Receiver: power to 3.3 V, ground to ground, output to another free pin.
The driver circuit: an ESP32 pin drives an NPN transistor through a 220 ohm resistor, switching the IR LED and its 11 ohm resistor from 5 V, with the receiver on 3.3 V
The driver circuit: an ESP32 pin drives an NPN transistor through a 220 ohm resistor, switching the IR LED and its 11 ohm resistor from 5 V, with the receiver on 3.3 V

A common mistake is weaker values: on the bench, a single 22 Ω, a 1 kΩ base resistor and a 50 percent carrier reached nothing across the room. The values above do.

How to set it up

  1. Learn the codes. Flash a sketch that only listens and prints, and press the original remote's buttons one at a time near the receiver. Capture power on and off, cool at several temperatures, each fan speed and each mode, and put the results in a table.

    We used the Arduino IDE, board "ESP32 Dev Module", serial monitor at 115200, and the library's receive-dump example (ReceiveDump in IRremote, IRrecvDumpV2 in IRremoteESP8266). A good capture looks like Protocol: COOLIX Code: 0xB2BF40 (24 bits). UNKNOWN means the protocol is not in the library; you will replay its raw timings instead.

  2. Build a firmware that sends and listens. If you would rather not write firmware, ESPHome does the whole job with no code: a remote_transmitter on the LED pin with carrier_duty_percent: 50%, a remote_receiver on the receiver pin, and a climate: block (coolix, climate_ir_lg, daikin, gree). It appears in Home Assistant as a thermostat. We went further because our units needed exact captured frames. Our board turns plain text commands from the network into IR frames and reports every remote press it hears:

    SEND RAW 38 <t1>,<t2>,<t3>,...
    AC COOL 24 AUTO
    AC OFF
    PING
    

    It replies OK, ERR <reason> or PONG, and remote presses come back as RX <protocol> <data> <bits>. Switch the receiver off while sending, or the board hears its own LED. A small Python service on our server translates between MQTT and this protocol, because a server is easier to change and log. When it works, AC OFF from a terminal makes the AC beep and shut down.

  3. Make it a thermostat in Home Assistant. An MQTT climate entity gives you the proper thermostat card. Home Assistant sends mode, temperature and fan as separate messages, but the AC wants one frame. A minimal configuration (placeholders throughout):

    mqtt:
      climate:
        - name: "Office AC"
          modes: ["off", "cool", "dry", "fan_only", "auto"]
          fan_modes: ["auto", "low", "medium", "high"]
          min_temp: 16
          max_temp: 30
          mode_command_topic: "ir/office-ac/mode/set"
          temperature_command_topic: "ir/office-ac/temp/set"
          fan_mode_command_topic: "ir/office-ac/fan/set"
          mode_state_topic: "ir/office-ac/mode"
          temperature_state_topic: "ir/office-ac/temp"
          fan_mode_state_topic: "ir/office-ac/fan"
          current_temperature_topic: "ir/office-ac/room-temp"
    

    Feed current_temperature_topic from any room sensor. Put toggles such as swing step or the display light on separate buttons.

    The middle layer is where the work is: keep one record per AC (power, mode, temperature, fan, swing). On any /set message, update that one field, encode the complete frame from the record and send it. Then publish every state topic back so the card does not snap to its old value. Publish state topics with retain set so the card survives a restart. When it works, moving the dial changes the AC within about a second.

A thermostat card for an infrared-controlled AC, showing mode, a temperature dial and fan speed, with swing and display buttons beside it
A thermostat card for an infrared-controlled AC, showing mode, a temperature dial and fan speed, with swing and display buttons beside it
  1. Add schedules. The AC is now a normal automation target: off at 7 pm on weekdays, on before people arrive, off if a door stays open.

  2. Add voice. Home Assistant's Assist handles "set the AC to 24" locally if the words match. Give the entity aliases such as "AC" and expose only what you need. Alexa and Google see the AC as a thermostat. The easy route is the paid Home Assistant Cloud subscription; the free route is a custom smart-speaker skill, which is what we run. Timed sentences like "turn the AC on in 25 minutes" need a small hub script behind them; Assist and the speaker both just call it.

  3. Find the spot. Infrared needs line of sight or a bounce off a light wall; aim at the indoor unit's display window. Test with the original remote from the board's position before mounting anything.

What goes wrong

The first two pitfalls apply if you use the Arduino IRremote library; IRremoteESP8266 decodes Coolix and most long AC frames itself.

  • Captures stop after the header. Some LG units start with an unusually long gap, and IRremote treats it as the end of the frame. Raise RECORD_GAP_MICROS to around 12000.
  • Long frames truncated. Coolix is 24 data bits, each byte followed by its inverse (48 bits on the wire), sent twice. Arduino IRremote has no Coolix decoder, so it prints only raw timings; IRremoteESP8266 decodes and sends it directly. For any frame a library does not know, print and replay the raw timings.
  • The library's encoder is ignored. Our LG AC uses a different header from the library's LG encoder. Build the frame from your capture; when a captured code and a generated one disagree, trust the capture.
  • The room overshoots under hub control. The LG remote sends a 28-bit frame for power and mode and a 36-bit one for temperature and fan. Sending temperature as the short frame let the room drift to 20 °C with the setpoint at 23 in our case, probably because the AC restarted its cool-down each time. Send the remote's exact frame. This is also why ESPHome's stock component did not suit that unit; for many ACs it is fine.
  • Weak range. Check the LED is not shaded. Ours was soldered upright under the ESP32 and garbled frames at 3 m; bent outward past the board edge, it decoded 20 of 20 at the same distance. Also meter your resistors: strips do get mislabelled, and a resistor that reads about 680 kΩ against its colour bands leaves the LED barely driven.
  • Toggles step twice. Swing step and similar codes must be sent exactly once, with no repeats.
  • Two identical ACs in one space. Identical units respond to identical codes. The only separation is placement: if the second AC beeps when you test from the board's spot, move the board.
  • Board offline after a router restart. Make the firmware retry Wi-Fi every 30 seconds, and add an alert if a board is unreachable for a few minutes.
  • The hub thinks the AC is on when it is not. Keep the receiver running so original remote presses update the hub.
The finished IR board on perfboard: an ESP32, transistor, resistors, receiver and an IR LED bent to point outward past the edge
The finished IR board on perfboard: an ESP32, transistor, resistors, receiver and an IR LED bent to point outward past the edge

Cost and time

Parts come to roughly ₹500 to ₹1,000 per board. Expect a weekend for the first one. The board runs on a USB adapter; any mains wiring for a permanent power point is a job for a licensed electrician, done with the power off.

Worth it?

Check ESPHome and IRremoteESP8266 for your brand first. For one bedroom it is a satisfying weekend project. For an office with three ACs and an argument about who left them on, it is one of the cheapest fixes in automation.

TDH Systems designs and builds custom automation hardware like this. See what we automate.

Written by Siddharth Agrawal, Founder and Director, TDH Systems.

Tell us what you have in mind. We will come back with a plan and a quote.

Start a project

Prefer email? Write to info@thydarkhour.com.