Introduction: TV Remote Controlled Light and Fan
Remember that time when your were watching your favourite movie on TV and you wanted to switch off/on lights or fan but were too lazy to get up..
Don't worry, we have a solution for you.
This project is about controlling your room lights and/or fan wirelessly, all while sitting on your couch. The reason why I chose this project was because TSOP receiver was the best suited component for a short ranged wireless communication.
Hardware components:
- IR receiver (generic)
- Arduino UNO & Genuino UNO or AVR Atmega328p if you want to make a permanent soldered circuit.
- HL-525 relay module/any relay board having 2 or more channels
- TV remote
Step 1: Understanding the Working of TSOP Receiver
Why we choose TSOP Receiver?
Firstly, it is really really cheap (Rs. 10 in India). Plus, you already have a transmitter with you i.e. the TV remote.
The TV remote sends Infrared signals at 38 kHz frequency and the TSOP receiver that I purchased can receive signals between 36-40 kHz. The pinout of the receiver may vary according to the model.
TV remote outputs high and low pulses at high frequency, thus, switching on and off the IR LED multiple times in a second corresponding to those pulses.
Whenever the LED is ON , the TSOP goes low and when the LED is OFF, the TSOP is high (which means that it is also high when it is idle).
Step 2: Understanding the Relay Module
These inputs, when receive a LOW, switch the relay on i.e. the switch is 'closed'.
I have posted a video of TV remote switching the relay on/off. Here's the connection for connecting the lamp to the relay (in image above).
In my module too, from left to right- the 3 pins are: NC (normally connected), COM (common), NO (normally open). Connect the live wire to the bulb as shown. You can solder the entire project and install it inside your switch board to control your tubelight, fan, lamp etc.
NOTE: On the left side of relay module, there are 3 pins: DVcc Vcc and GND. I strongly suggest you to remove the jumper and give the DVcc pin a separate 5V supply because it is connected to an optocoupler (which prevents physical connection between high ac voltage and the microcontroller) so that in case of spikes, your microcontroller is not damaged.
Step 3: Schematic
How TSOP is connected?
From left to right- OUT , GND , VS.OUT is connected to pin 11. VS connected to 5V pin of arduino and GND connected to gnd pin of arduino. LED's cathode is connected to pin 3, which when LOW , will switch on the led.
The fritzig schematic is attached herewith.
You can ignore the LED. and connect the relay pin instead.(as shown in the next image)
Give the 'DVcc' a separate 5V
Step 4: Upload Code
Download the code attached here.
Upload the code in arduino UNO using arduino IDE.
Serial monitor
A hex code will be displayed on monitor, everytime you press a button on the remote.
The relay will be turned on and off correspondingly.