FAQ
TL;DR: Expect “several hundred lines of code” and a microcontroller because consumer IR remotes use a “proprietary way of encoding.” Build it with an Arduino, an IR receiver, a driver transistor, and a relay to switch 110/220 V safely. [Elektroda, Rick Curl, post #21678038]
Why it matters: This FAQ shows students and hobbyists how to make a TV‑remote‑controlled mains switch safely and quickly, or pick a ready-made alternative.
Quick Facts
- Scope: On/off control of bulb/fan using a TV/AC IR remote, Arduino, IR receiver, transistor, and relay. [Elektroda, Adnan Ali Saifi, post #21678040]
- Safety: Mains 110/220 V AC is lethal—use proper isolation and relays/enclosures. [Elektroda, David Ashton, post #21678039]
- Signaling: Example student circuit uses burst modulation around ~5 kHz to avoid ambient light; protocols vary. [Elektroda, David Ashton, post #21678041]
- Parts option: HT12E/HT12D encoder/decoder pair avoids protocol decoding complexity. [Elektroda, David Ashton, post #21678041]
- Time-saver: Off‑the‑shelf RF outlet kits cost ~US$30 and work through obstacles. [Elektroda, David Ashton, post #21678039]
What’s the exact goal this thread tackles?
Switch a 220 V light (and similar loads like a fan) on/off using an infrared sensor and a common TV/AC remote, built as a simple student project. [Elektroda, Adnan Ali Saifi, post #21678040]
Can I use a TV/AC remote directly with Arduino to toggle a relay?
Yes. Use an IR receiver module to decode the remote and have Arduino drive a transistor that energizes a relay. Remember, “each company…has their own proprietary way of encoding,” so you must decode and map buttons first. [Elektroda, Rick Curl, post #21678038]
Do I really need a microcontroller, or can I keep it all‑hardware?
You can skip protocol decoding by using an HT12E (encoder) at the transmitter and HT12D (decoder) at the receiver, then drive the relay. This simplifies logic but ties you to your own remote, not a TV remote. [Elektroda, David Ashton, post #21678041]
What IR modulation should I plan for in a simple build?
To reject ambient light, modulate your IR LED in bursts at a chosen frequency; an example student circuit used about 5 kHz. Remote controls use different schemes, so treat 5 kHz as a didactic example, not a universal setting. [Elektroda, David Ashton, post #21678041]
How do I stay safe when switching mains (110/220 V AC)?
Use a rated relay or SSR with proper creepage/clearance, an enclosed mains section, and strain relief. Keep low‑voltage and mains grounds isolated. If unsure, use a certified plug‑in module instead. Lethal voltages demand caution. [Elektroda, David Ashton, post #21678039]
Which Arduino library should I use to decode common TV remotes?
Use the IRremote library. It supports many protocols (NEC, Sony, Samsung, RC5/RC6, JVC, Panasonic, LG, and more), making button capture and mapping straightforward. [IRremote - Arduino Libraries]
Give me the 3 basic steps to build it with Arduino.
- Capture IR codes from your TV/AC remote using an IR receiver and the IRremote example to identify button values.
- Map chosen codes in your sketch to toggle a GPIO output state variable.
- Drive a transistor + flyback diode to energize a relay module that switches the lamp. [Understanding Sony IR remote codes, LIRC files, and the Arduino library]
What if sunlight or room lights cause false triggers?
Ambient IR can fool simple receivers. Use a modulated IR link and a demodulating receiver tuned to your burst frequency, add shielding, and position the sensor away from direct light. [Elektroda, David Ashton, post #21678041]
Is there a quick alternative if my deadline is near?
Yes. Buy a multi‑outlet RF remote kit. Around US$30 gets several plug‑in modules and a handheld remote that works through furniture and walls. [Elektroda, David Ashton, post #21678039]
What parts list should I start with for the student build?
Typical: Arduino (e.g., Nano/Uno), IR receiver module, IR LED (for learning/feedback), NPN transistor + base resistor, flyback diode, relay or SSR module, and a fused enclosure for mains wiring. [Elektroda, David Ashton, post #21678041]
What is Arduino Nano?
A compact, breadboard‑friendly Arduino board originally based on the ATmega328P (16 MHz, 32 KB flash). It offers Uno‑like functionality in a smaller form factor for embedded projects. [Arduino Nano]
What is Tuya?
Tuya (Tuya Smart) is a Chinese IoT platform‑as‑a‑service provider that powers many branded smart‑home devices and ecosystems worldwide. [Tuya Inc.]
What is CAN bus?
CAN bus is a differential, multi‑master serial network used in vehicles and industry, supporting robust, prioritized messaging up to 1 Mbit/s in Classical CAN. [CAN bus]
What is OpenBeken?
OpenBeken is open‑source firmware that replaces vendor firmware on Tuya‑type modules (e.g., BK7231), offering Tasmota‑like configuration, MQTT, and Home Assistant integration. [GitHub - openshwprojects/OpenBK7231T_App]