šŸ”¶ KY-022 / TSOP1838 Infrared Receiver Module — IR Remote Detector for Arduino / ESP32 / ESP8266


šŸ“¦ Overview

Compact IR receiver module based on the TSOP1838 demodulating IR sensor. Receives infrared remote signals (ā‰ˆ38 kHz) and outputs clean digital pulses suitable for decoding by microcontrollers. Ideal for remote control decoding, WLED / lighting triggers, home automation inputs and general IR-based control with Arduino, ESP8266, ESP32 or Raspberry Pi.


āœ… Key Benefits


šŸ”Œ Quick Wiring

KY-022 Pin   -> Microcontroller
-----------------------------
VCC          -> 3.3V or 5V (module dependent)
GND          -> GND
OUT          -> Digital input (e.g. GPIO4 on ESP32, D2 on Arduino UNO)

For ESP32/ESP8266 use 3.3V signalling. Point the IR receiver at the remote, avoid direct sunlight/strong IR sources while learning codes.


🧩 ESPHome — IR Receiver (Discovery + Action)

Click to expand — ESPHome YAML (use to discover codes and trigger a relay)
esphome:
  name: ir_receiver
  platform: ESP32
  board: esp32dev

wifi:
  ssid: "YOUR_SSID"
  password: "YOUR_PASS"

logger:
  level: DEBUG

api:
ota:

remote_receiver:
  pin:
    number: GPIO4        # <- change to your KY-022 OUT pin
    inverted: false
  dump: all              # prints received codes/protocol (use for discovery)

switch:
  - platform: gpio
    pin: GPIO5           # relay / device to control
    id: relay_output
    name: "IR Controlled Relay"
    restore_mode: RESTORE_DEFAULT_OFF

# Example: trigger action for NEC protocol (replace address/command after discovery)
remote_receiver:
  pin:
    number: GPIO4
  on_nec:
    - address: 0x00FF00   # replace with discovered address
      command: 0xA25D     # replace with discovered command
      then:
        - switch.toggle: relay_output
        - logger.log: "NEC code received — relay toggled"
  

🧩 Arduino — IR Receiver (Discovery + Action)

Click to expand — Arduino sketch using IRremote (discover codes, toggle relay)
// Arduino UNO — KY-022 using IRremote library
// Connect KY-022 OUT -> D2 (INT0). Install "IRremote" via Library Manager.

#include <IRremote.h>

const int RECV_PIN = 2;      // KY-022 OUT
IRrecv irrecv(RECV_PIN);
decode_results results;

const int RELAY_PIN = 8;     // relay output pin

void setup() {
  Serial.begin(115200);
  irrecv.enableIRIn();
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW);
  Serial.println("IR receiver ready. Press remote buttons to discover codes.");
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.print("Raw value: 0x");
    Serial.println(results.value, HEX);
    // Example: match a discovered code (replace 0xA25D with your discovered value)
    if (results.value == 0xA25D) {
      digitalWrite(RELAY_PIN, !digitalRead(RELAY_PIN)); // toggle relay
      Serial.println("Matched code - toggled relay");
    }
    irrecv.resume(); // receive next value
  }
}
  

šŸ’” Possible Uses


šŸ“¦ Package & Notes

Tip: Use the ESPHome dump: all feature or the Arduino serial monitor to capture remote codes. Replace the example hex values in the code above with your discovered values to trigger actions.


KY-022 TSOP1838 Infrared Receiver Module — IR Remote Detector for Arduino ESP32 ESP8266


✨ Fast Shipping • šŸ”’ Secure Checkout