TV Remote POC

The goal


The purpose of TV remote proof of concept is to prove the infrared control functionality can be used in my home automation project. The goal is to make four buttons to send four different working IR codes, thus making changes to the TV channels. The implemented buttons are buttons 1, 2, and 3, and the on / off button.


The research phase


Figure 1: The schematics


The research phase consisted of my previous simple project involving IR reveinig unit tied to Arduino for TV remote data gathering. The data of interest cosisted of the remote codes and the used encoding. Ken Shirriff's library "IRremote" provides a couple of very useful examples which work out-of-the-box for gathering such data. I used the IRrecvDemo to gather the following codes:



  • 807F807F - On Off

  • 807F00FF - 1

  • 807FE01F - 2

  • 807F609F - 3


As for the encoding, I used the IRrecvDump example, which calculates and displays the encoding. The encoding that my remote uses is NEC with 32 bits. The bits count is an important method parameter when sending the hex code, so it is worth noting.



The design and build phase


Figure 2: Finished build - a working POC


The design was growing during the different research phases. The initial plan included only the buttons. As I'm quite new to electonics and integrated circuits, it took a bit more time to hook up the buttons as expected. Arduino "Button" article pointed me in the right direction. As a reminder to other people new in this field, the input reading pins comming from the arduino to the button should be pulled down using a resistor, usually 10kΩ. If this is not done, when the button is not pressed, the input state is floating. This means it is somewhere between 1 and 0. In my case, this resulted in buttons behaving as pressed when they were released. I was testing the buttons working by writing out values on serial console.


When the buttons were done and tested, I hooked up the IR led. It seems the IRremote library has a hard-coded pin for sending, which I had some difficulty finding. The "Arduino Remote Control Tutorial" by Oyvind Nydal Dahl vas very helpful for that. The pin in question is PWM pin 3 on Arduino Uno. Once that was determined, I first used the normal white LED for testing. The LED turned on for less than a second, which assured me that I have the correct pin.


Figure 2 shows the final prototype hookup plan.


Software


As previously mentioned, the base for this project was IRremote library, which has many handy features for sending and receiving codes. This effectively hides the true IR comunication protocols in the lower layers and allows the user to quickly develop the desired functionalities. Even though the desired encoding might be entirely custom, the library has the ability to send the raw unencoded data.


But, first of all, let's start with the buttons. Initially I was reading the button input statefor as long as the button was pressed. This would produce a lot of sends. I wanted to have one send per button press. To handle that I started to track push button state changes. This now allows to send a single IR command on a button press, thus potentially saving the battery life.


For sending the IR code I use the SendNEC method.


The test phase


The testing was done in separate stages. First stages (button testing) were consisted of printing the debugging messages on the serial monitor. As previously mentioned, I used a normal white diode for testing the correct send port. Lastly, the true test was using the remote on the TV. The tv was turned on and off, and I was able to change the channels to any one-, two-, and three-number combination of numbers 1, 2, and 3. The project was thus deemed successful.


The future plans


This project allowed me to learn the workings of the IR remotest, the IR codes and how to use the IRremote library. The next step is swapping the button interface with 433MHz wireless interface and controling it from some sort of web site. To achieve this, I will have to learn how to properly tie the rfm12bsp to the Raspberry Pi and send the data from a Node server.

IR, IRremote, Infrared, Home Automation