Back to All Blog Posts
Tutorial EltroNerd Engineering

IR Remote to Wi-Fi Universal Remote using ESP32

You want to build an IR Remote to Wi-Fi Universal Remote using ESP32.

IR Remote to Wi-Fi Universal Remote using ESP32

Most TVs, Air Conditioners, and other appliances still use IR remotes.
But what if you could control all of them from your phone or Wi-Fi network?
In this project, we will build an IR-to-Wi-Fi Universal Remote using the ESP32, which can learn IR signals and replay them over Wi-Fi.


Hardware Requirements

  • ESP32 Development Board
  • IR Receiver Module (e.g., VS1838B, TSOP38238)
  • IR LED (for transmitting signals)
  • Resistor (100–220Ω for IR LED)
  • Jumper wires + Breadboard
  • USB cable for programming

Working Principle

  1. Learn IR Codes:

    • Point your TV/AC remote at the IR Receiver.
    • The ESP32 reads the unique IR code for each button.
  2. Store IR Codes:

    • Each button’s code (e.g., Power, Volume Up, Temp Down) is stored in ESP32 flash/EEPROM or hardcoded.
  3. Replay IR Codes:

    • When triggered via Wi-Fi (webpage, mobile app, MQTT), the ESP32 sends the stored IR signal through the IR LED.
    • Your TV/AC thinks you pressed the real remote button.

Arduino Code Example

We’ll use the IRremoteESP8266 library.
Install from Arduino IDE → Library Manager.

c
#include <WiFi.h>
#include <ESPAsyncWebServer.h>
#include <IRrecv.h>
#include <IRsend.h>
#include <IRutils.h>

#define IR_RECEIVE_PIN 15
#define IR_SEND_PIN 4

const char* ssid = "Your_SSID";
const char* password = "Your_PASSWORD";

IRrecv irrecv(IR_RECEIVE_PIN);
IRsend irsend(IR_SEND_PIN);
decode_results results;

AsyncWebServer server(80);

String savedCode = "";

void setup() {
  Serial.begin(115200);

  // IR setup
  irrecv.enableIRIn();
  irsend.begin();

  // Wi-Fi setup
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("\nWi-Fi connected!");
  Serial.println(WiFi.localIP());

  // Web server endpoints
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
    String html = "<h1>ESP32 IR Remote</h1>"
                  "<p><a href='/send'>Send IR Code</a></p>";
    request->send(200, "text/html", html);
  });

  server.on("/send", HTTP_GET, [](AsyncWebServerRequest *request){
    if (savedCode != "") {
      Serial.println("Replaying saved IR code...");
      uint32_t codeValue = strtoul(savedCode.c_str(), NULL, 16);
      irsend.sendNEC(codeValue, 32);
      request->send(200, "text/plain", "IR Code Sent!");
    } else {
      request->send(200, "text/plain", "No code saved yet.");
    }
  });

  server.begin();
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.print("Received IR code: ");
    Serial.println(resultToHexidecimal(&results));
    savedCode = resultToHexidecimal(&results);
    irrecv.resume();
  }
}

** How to Use **

Upload the code to ESP32.

Open Serial Monitor at 115200 baud.

Press any button on your remote → ESP32 will print the IR code.

That code is stored as savedCode.

Open your ESP32’s IP address in browser → click “Send IR Code” → appliance responds!

** Extensions **

Store multiple IR codes for full remote functionality.

Create a mobile app or use Home Assistant integration.

Add MQTT so you can control appliances via Alexa/Google Home.

Try this project in your browser

Compile code and simulate hardware output with EltroNerd Cloud IDE.

Launch Cloud IDE