loading

A few days ago, I published an IBLE on how to hack a remote.

At the time, my mind was fixated on getting a Home Automation Project kicked off as soon as possible, and I decided to take the route as demonstrated in the above mentioned IBLE.

I received a lot of helpful hints from fellow IBLE community members following which I decided to get of the speeding horse and spend some more time on researching a less invasive (and non-destructive) solution towards achieving my objective.

This weekend, I spent some time reading up on the fundamentals of Infra Red (IR) reception and transmission, and a a lot of these topics gave me a feeling of being back in the Advanced Physics class room during my college days.

With what I could learn within the span of a day, I came up with a quick prototype on how I could clone a remote instead of hacking one (which zombie-fies it in the process) .

Before I begin, I would like to clarify that this work is based on a number of existing resources online from who I have learned something new this weekend. Therefore, these resources have been duly regarded where applicable.

This IBLE aims to highlight the process of learning more than anything else.

With that out of the way, let's get cracking!

Step 1: The Parts List and Knowledge Base

Before we start of with the parts list, I would recommend that you quickly read up on the basics of Infrared (IR) Reception and Transmission from these resources on the web:

  1. IR Communication from https://learn.sparkfun.com/
  2. Using an Infrared Library on Arduino from https://learn.adafruit.com/

The second article is very well detailed and demonstrates the use of an Arduino IR Library called IRLib.

My prototype is based on the examples that come with the installation of the IRLib library Link to download the library can be found at this blog.

In addition to the knowledge base, you will need the following:

  • The Arduino Uno or clone (UNO recommended as I've not tested on any other platform)
  • A pair of IR receiver and transmitters - I used a brand named Three Legs from Amazon.com
  • A 330 or a 220 Ohm resistor - I used the 220 (color code Red-Red-Brown) because I had one handy
  • The usual bread board, connectors, and a PC with the Arduino Environment installed
  • A test candidate - such as the ubiquitous Samsung LED Monitor with a remote (caution: the wife is in charge of the TV remote on weekends!)

Step 2: Installing the Arduino Library - Things to Know

There are infinite resources on how to install Arduino libraries. But one of the main problems that I faced with the easy approach are conflicts with the libraries installed previously.

Example of an Arduino Library Collision:

  • I recently purchased a new multi-line LCD display for which the name of the Arduino library is LiquidCrystal.
  • I followed the manufacturers instructions to install the library via the Arduino user interface.
  • Almost immediately, there were issues and none of my LCD sketches would compile!
  • There was a library called LiquidCrystal already installed in my Arduino environment, and I missed that part of the instruction where I had to manually rename or move an existing library.

Therefore, here's what to do before you install any library for Arduino:

  1. Libraries that come as part of the Arduino installations are typically located here on a Windows machine
    • C:\Program Files (x86)\Arduino\libraries\LibraryName
  2. Third party libraries are usually located in the "Contributed" Library folder here:
    • C:\Users\YourName\Documents\ARDUINO\libraries\LibraryName
  3. If the library you're downloading has the same name as anything existing in these folders, it's bound to cause a collision!

Therefore, make sure that you move the library that already exists to a different location before installing an identically named library.

Once you have done so, you can proceed to install the new Arduino library based on instructions available online.

If you've followed these steps correctly, the new library and any examples that come with it, should be available to you from the following path in your Arduino environment:

Library:

Sketch > Include Library > IRLib-master

Library Examples:

File > Examples > IRLib-master > (various example sketches to choose from)

Step 3: Identifying the IR Receiver, Sender LED and Their Connection Terminals

The resources I've mentioned in the past steps clarify IR Receivers and Senders. Nevertheless, here's a quick rundown on how to identify them.

An IR Receiver:

  • Is dark, a bit bulkier than the IR sender
  • Has 3 terminals, usually of the same length
  • Some receivers like the one I've used come with what looks like a helmet
  • The Receiver part is usually exposed, and sticks out to one side
  • With the receiver part facing you, the terminals from left to right are the Receiver, the Ground (-) and the 5V Power pins

An IR Sender LED:

  • Looks like any other LED, except that it's plain transparent
  • Has two terminals , one longer and the other
  • The short terminal is Ground (-) and the longer one is wired to the Digital OUT pin on the Arduino

NOTE:

  1. Unlike a regular LED, an IR LED emits Infrared light and is therefore invisible to the naked eye
  2. Most smart phone cameras can display the IR light from the LED during transmission

Step 4: Wiring the Set Up - Simple Isn't Always Simple!

The schematic for the wiring can be found at this tutorial from Sparkfun and is straight forward except for a few minor but important considerations.

USING THE ARDUINO DIGITAL PINS:

If I've understood correctly, I had to pay attention to the DIGITAL PINS used to wire the IR Receiver and the IR Sender LED (feel free to correct me if I'm off track here)

Simply switching to other PINs on the UNO for the IR Sender or Receiver may not always work!

Reasons(s):

  1. The IRLib library assumes default settings for many number of Arduino and other boards
  2. For UNO or older boards, the usable IR LED Sender PINs are 3 or 9
  3. Therefore, if your #3 or #9 PIN is already taken up by another resource, you'll need to make changes to the IRLib code before using a different PIN for the IR Sender LED
  4. Likewise, using a PIN other than #11 for your IR Receiver will require changes to the Arduino sketch

If so, the library installation comes with excellent documentation that is typically located here:

C:\Users\YourName\Documents\ARDUINO\libraries\IRLib-master\manuals\IRLibReference.pdf (or .docx)

In the PDF version, refer to the following sub sections:

"1.4.1. Interrupts and Timers" - on what defaults to use and why you may not want defaults
"1.4.2 Changing Defaults" - on how to change defaults if required

The UNO here was totally dedicated to this IBLE and therefore such advanced changes were unnecessary

About the Remote:

  • There were no presumptions made as far as the test candidate went.
  • Other than the fact that there was an identification number on the keypad (above the SAMSUNG logo), no effort was put into additional research on this remote

Step 5: The Arduino Sketch

Attached here is a self-documented sketch that I developed after having gone through the examples that came with the IRLib installation. My circuit however, skips the button and instead uses the Serial window commands to trigger the IR transmission.

Once again, this example is very simple, but was definitely able to achieve the following objectives:

  1. I was able to capture a pair of codes from my candidate remote and store them for later use
    • Example: A pair of Power On and Power Off codes. Or, a pair of Mute On and Mute Off codes
  2. By sending a 'p' command from the Serial Window, I was able to play back and write out the codes captured
  3. By sending a 't' command, I was able to transmit the codes one after the other
  4. The Sketch would report an error if a command other than 'p' or 't' was sent via the Serial window

NOTE:

  • Where applicable, the original comments in the code have been preserved
  • Any new code that I've added has been labelled appropriately

Step 6: Testing the IR Reception

Based on the previous steps, compiling and flashing the sample sketch to the UNO should be uneventful unless there are issues with the IRLib library installation or if you aren't using the default digital pins on the UNO.

Before you begin:

  • Make sure that you block of the IR reception on your target appliance
  • Bringing up the Serial window will initialize the IR receiver and display basic instructions on how to proceed with the test

When ready, you should be able to capture a couple of codes and then play them back with the 'p' command. However, do not close the Serial Window!

Observations on IR Protocols

  1. Manufacturers use different IR Protocols to communicate between the remote control and appliance
  2. If IRLib doesn't understand this protocol, the IR Receiver will capture the raw sequences of marks and spaces, but will be unable to read the signal protocol code
  3. This fact is clear in this case because the output indicates a Decoded value of 0 bits
  4. Therefore, without the IR protocol, the Arduino will have to transmit the entire array of marks and spaces to the appliance to influence its functionality
  5. This is a generic way in which an IR signal can be transmitted to a target - but it's not always so simple because some IR protocols are very complex to emulate

Now that we have the marks and space sequences, we should be able to perform the IR Transmission test.

Step 7: Testing the IR Transmission

Before you begin:

  • Make sure that you have not closed the Serial window
  • Remove the obstruction placed in front of the target appliance
  • Ensure that the IR Sender LED has a clear line of shot to the target appliance

Remember!

  • You won't be able to see the LED in action unless you're holding up a mobile phone camera in front of it
  • Most IR senders flash signals out at extremely high rates of 38000 cycles per second, or 38 KHz
  • Therefore, it's not unusual to see the IR Sender LED flash several times when viewed under the camera lens

When ready, type a single 't' character in the Serial window and click Send.

If all is well, your appliance should respond to the signal!

  1. In this case, the monitor powered On and Off successfully
  2. I quickly repeated the test by capturing the codes for the Mute On/Off functions on the remote
  3. Sure enough, the Arduino was able to influence the Mute functionality on the monitor successfully!

Step 8: Note on Signal Transmission and Response Times

Based on your target appliance and the distance, you may have to change the wait times between your transmissions when calling the transmitCodes(n) function in the code.

Reason(s):

  1. Your target appliance will take time to respond to the signal - my monitor takes north of 3 seconds to come on
  2. This delay is compounded by the distance between the remote and the appliance - larger the distance, slower the response
  3. Remote controls get around this by sending out a volley of repeated signals to make sure that it reaches the other end
  4. Here however, we transmit signals only once and the appliance may not always respond to the second signal
  5. In short, you have to wait longer to send out the second signal after the first one has been transmitted

Therefore, you may have to experiment with the transmission times before things can work as expected.

Step 9: The Pros and Cons

Let's summarize some Pros and Cons of this approach.

The Pros:

  • A clean solution - One processor can use a single IR Sender to transmit different codes to the target appliance based on programming logic
  • It's relatively easy to extend this solution to program in new codes for a completely different appliance and yet have the same set up control multiple appliances
  • Less invasive than other solutions such as hacking a remote - demonstrated in my other IBLE

The Cons:

  • While it's easy to capture IR signal codes, the IR protocol codes however aren't that easy to read
  • Different manufacturers use different methods of transmitting IR signals to targets - some of them may have a specific number of times a signal may have to be sent for the target to respond
  • These issues can take a lot of time to figure out which makes hacking a remote physically seem a lot easier!

Have fun and thanks for reading my IBLE!

<p>Thanks all for reading my IBLE!</p>
Very good tutorial, I made a shot at a similar problem and discovered that my remote used a tweaked protocol. I found it out using a signal analyzer and then was able to emulate simple standard codes. My Samsung tv uses standard Sony protocol.
<p>Nice. This will come in handy when I get that do some automation. Thanks for posting.</p>

About This Instructable

4,248views

111favorites

License:

Bio: I'm a Mechanical Engineer turned IT Professional . I came into the Information Technology world because someone challenged me to. But at heart, I'm ... More »
More by andymenon:Monoprice Mini: Remove Broken Filament From Nozzle Build a Custom ESP8266 Arduino WiFi Library Raspberry Pi 2 Wifi Struggles and Solution 
Add instructable to: