ESP32 KY-005 Infrared Transmitter Module
Overview
The KY-005 is an infrared transmitter module that emits infrared light at a wavelength of 940 nm. It is commonly used in remote control applications and can be paired with the KY-022 Infrared Receiver Module for infrared communication projects.
About KY-005 Infrared Transmitter Module
The KY-005 is an infrared (IR) transmitter module designed to emit infrared light at 940 nm, making it ideal for remote control applications. It consists of a 5mm infrared LED and operates with a forward voltage of 1.1V and a current of 20mA.
⚡ Key Features
- 940 nm Infrared Emission – Suitable for IR remote control and data transmission.
- Adjustable Resistor Requirement –
- 3.3V input → Use a 120Ω resistor
- 5V input → Use a 220Ω resistor
- Simple Digital Control – Easily interfaces with ESP32, Arduino, and other microcontrollers.
- Pairs with KY-022 – Works alongside the KY-022 Infrared Receiver Module for IR communication systems.
With its compact design and reliable performance, the KY-005 is an excellent choice for wireless IR control applications. 🚀
Where to Buy
Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.
Technical Specifications
Pinout Configuration
The VCC
pin is used to supply power to the sensor, and it typically requires 3.3V or 5V (refer to the datasheet for specific voltage requirements). The GND
pin is the ground connection and must be connected to the ground of your ESP32.
Pin (S):
Signal pin, connects to the microcontroller's GPIO pin.Pin (middle):
Can be connected to ground if an additional resistor has been soldered onto the module.Pin (-):
Ground pin, connects to the ground of the circuit.
Wiring with ESP32
Troubleshooting Guide
Common Issues
❌ Infrared Signal Not Emitted
Issue: The module does not emit an infrared signal.
Solutions:
- Verify that the correct series resistor is used based on the input voltage (e.g., 220Ω for 5V).
- Ensure all connections are secure and correctly placed.
- Confirm that the microcontroller's GPIO pin is configured correctly in the code.
- Test the infrared LED with a camera to see if it lights up when active (infrared light is visible to most digital cameras).
🔥 Overheating or Damage to the Module
Issue: The module becomes hot or is damaged during operation.
Solutions:
- Check that the appropriate series resistor is in place to limit current through the LED.
- Ensure the input voltage does not exceed the module's specifications.
- Inspect for any short circuits or incorrect wiring that could cause excessive current draw.
Debugging Tips
🔍 Serial Monitor
Use the Serial Monitor to check for error messages and verify the sensor's output. Add debug prints in your code to track the sensor's state.
⚡ Voltage Checks
Use a multimeter to verify voltage levels and check for continuity in your connections. Ensure the power supply is stable and within the sensor's requirements.
Additional Resources
Code Examples
Arduino Example
#include <IRremote.h>
IRsend irsend;
void setup() {
Serial.begin(9600);
Serial.println("KY-005 Infrared Transmitter Test");
}
void loop() {
for (int i = 0; i < 3; i++) {
irsend.sendNEC(0xA90, 32); // Send NEC protocol with command 0xA90
delay(40);
}
delay(5000); // Wait 5 seconds before sending the signal again
}
This Arduino code utilizes the IRremote library to send an NEC protocol infrared signal with the command 0xA90
. The signal is sent three times with a 40ms delay between transmissions, followed by a 5-second pause before repeating. This setup is commonly used to control devices like TVs or other appliances that accept infrared commands.
ESP-IDF Example
This ESP-IDF code sets up the KY-005 Infrared Transmitter using the RMT (Remote Control) peripheral of the ESP32. It configures GPIO17 as the output pin and initializes the RMT driver to transmit an infrared signal. The IR protocol can be customized to match the target device's requirements.
ESPHome Example
remote_transmitter:
- platform: gpio
pin: GPIO17
carrier_duty_percent: 50%
button:
- platform: template
name: "KY-005 Send IR Signal"
on_press:
- remote_transmitter.transmit_nec:
address: 0x00FF
command: 0xA90
This ESPHome configuration sets up the KY-005 Infrared Transmitter on GPIO17. It uses the NEC protocol to send an infrared command when a button is pressed, making it ideal for controlling TVs or other IR-enabled devices.
PlatformIO Example
platformio.ini
[env:esp32]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
z3t0/IRremote
PlatformIO Example Code
#include <Arduino.h>
#include <IRremote.h>
IRsend irsend;
void setup() {
Serial.begin(115200);
Serial.println("KY-005 Infrared Transmitter Test");
}
void loop() {
Serial.println("Sending IR signal");
irsend.sendNEC(0x00FF, 32);
delay(5000);
}
This PlatformIO code initializes the KY-005 Infrared Transmitter using the IRremote library. It sends an NEC protocol signal every 5 seconds, making it suitable for testing IR communication.
MicroPython Example
import machine
import time
IR_TX_PIN = machine.Pin(17, machine.Pin.OUT)
def send_pulse():
for _ in range(32):
IR_TX_PIN.value(1)
time.sleep_us(562)
IR_TX_PIN.value(0)
time.sleep_us(562)
while True:
print("Sending IR signal")
send_pulse()
time.sleep(5)
This MicroPython script configures the KY-005 Infrared Transmitter on GPIO17. It simulates an NEC-like IR signal by toggling the pin on and off rapidly, mimicking the transmission of an infrared command.
Conclusion
The ESP32 KY-005 Infrared Transmitter Module is a powerful KY-0xx module sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.
For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.
Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.