This post is about a simple project that was the basis of anther project posted on my blog. In this project, we are going to show how to use Arduino as a remote control for a TV. The requirement for the project was: a TV is connected to a security camera, camera is always ON, and we want to turn the TV ON/OFF from a distance/angle that the TV infrared (IR) remote does not support, please see Figure-1 below.
Figure-1 TV, Security camera and the Arduino mounted on the lower left side of the TV |
As you know, the IR remote that comes with the TV works at a
line of sight distance: this means you have to be facing the TV to be able to
use the remote. The TV you see in Figure-1 was placed in the second floor and
we want to turn it ON using a device placed at the first floor. Usually, the
best thing to turn power ON/OFF is to use a relay, well that is true but note
that nowadays TV needs to be turned ON using a remote after turning the main
power ON. Nevertheless, the relay had to be controller from anther location,
the first floor, this made things a little bit complicated!!
Best engineering practice is to divide the problem into
parts, called divide and conquer approach. First, the simple part: using a
relay will only help to turn on the power to the TV; but, if we connect the TV
and an Arduino to the relay then relay will power the TV and in the same time
power the Arduino. Bingo, think of the idea of using the Arduino as a remote: connect
an Infrared (IR) LED to it and let it send the ON signal to TV after main power
was turned on using the relay. What about the OFF signal? No need for it since the
relay will turn the TV OFF anyway. Seems simple project!! It is simple but the
relay was placed next to the TV, at the second floor, and controlling the relay
was done from the first floor. Hence, the relay had to be controlled via Radio
Frequency (RF)
Fortunately, a relay that can be controlled via Radio
Frequency (RF) was available at hand. The relay comes with anther unit, a push
button connected to a RF unit; push button used to turn the relay ON/OFF. Neither
the details of the relay unit nor the details of the RF unit are available at
this time; somebody else bought it, many thanks to him.
Let us talk about the software side then we can talk about
physical connection. To use the Arduino as an IR remote you need IR LED and you need
to know the protocol and codes your TV use to communicate with its actual IR
remote; M. McCracken explains this in details in his post and provides useful
links about IR protocols and codes each TV use (you may need to be logged as
registered user to hifi-remote.com). One great thing about Arduino, you can
find library for anything you need; some people already did a lot of work using
Arduino and made their software available to public. One name to mention here
is Ken Shirriff’s work to provide an open source multi-protocol IR library for
the Arduino; currently, his library is included with Ardunio and Energia
distributions.
You can easily figure out the rest of steps regarding using
Ardunio as an IR remote: either use the links on McCracken post to lookup the
protocol your device uses and the associated ON code for your device or you us
an IR detector to decipher the protocol and the codes your IR remote sends
based on the Ken Shirriff’s library. One
thing to note when you are programming your Arduino to mimic a remote sending
ON signal, it is timing; keep reading the hardware part to know more….
Hardware setup is simple; see Figure-2 and Figure-3 below.
The multi-outlet has the relay plugged to the top receptacle and the lower
receptacle has the camera AC-DC convertor plugged to it. The relay its self is
powering both the TV and the Arduino AC-DC convertor using the white extension
cord. Next, let us talk about the Arduino hardware. This project used ArduinoOSEPP UNO hardware; I have to admit that during the testing period, more than a
month, the board never stopped responding or malfunction due to repeated
restarts. On Figure-3, you can see that the IR LED is connected to a PCB
breadboard and an additional resistor is used to limit the current going to IR
LED; on the UNO board pin 11 and the ground pin are used to connect the IR LED.
Note that the whole setup was mounted to the wall next to the TV such that IR
LED is positioned as close as possible to the IR detector found in the TV. A
simple AC-DC converter provides the input voltage for OSEPP UNO, 6-12 volts
allowed, in this project an AC-DC 12 volts convertor was used with no
issues. One final note, when you program
the Arduino, you will need to add some delay just before sending the ON signal
using Pulse Width Modulation, this will the allow some time for the TV to
initialize and actually turn the IR detector on. Also, it is better to add the
code to send ON signal in the setup part of the Arduino code.
Figure-2 Wiring setup showing a picture of the relay on the bottom |
Figure-3 OSEPP Arduino mounted next to the TV; note IR LED is in front of the IR detector inside TV |