Universal IR Remote Control using Arduino and Android App - Internet of Things

Universal IR Remote Control using Arduino and Android App

Arduino and Android based Universal IR Remote Control

I started this project in order to get rid of various remotes at my home and build something single which could incorporate features of all of them. I got this idea when I saw one of my friends mobile phone with built in IR blaster, at that time I decided not to buy a similar phone rather make my own device which should be compatible with my existing handset. So here we are going to Convert an Android Phone into an IR Remote using Arduino to control various devices at home.

Components Required:
·         Arduino Uno
·         IR LED
·         TSOP-IR receiver (1838T)
·         Bluetooth module (HC05)
·         Android Device (Phone, Tablet, etc.)

Working Explanation:
Generally we use two remotes to operate TV at home, one for television and one for Set-Top Box so here in this Project I am targeting these two remotes and making an Android Phone working as IR Blaster so that TV can be controlled with the Phone, without touching any of the Remotes.
Using an Arduino Uno board just made it easier for me to deal with the IR decoding and encoding part. The custom made shield just adds on to the convenience part of this project. The shield consists of a TSOP IR receiver (1838T), an IR LED and a Bluetooth module (HC-05), see the image below:
You can either build the custom shield or can directly connect the components to the Arduino as shown in the Circuit Diagramin below section.
Before moving forward let us first discuss about how the IR remotes work. Most of the IR remotes work around 38 KHz frequencies (this is the reason why I have chosen 1838T). On further involving into this topic one will recognize that theres no fixed representation for zeros and ones in these IR data transmission methods. These codes make use of various encoding techniques which we study in our engineering syllabus (since I am an electronics engineering student). The significance of 38 KHz is that it is the frequency at which signal oscillates when logically high i.e. this is the carrier frequency of the signal. Have a look at the picture below; this is an example of NEC Protocol. This will make your concept more clear:
So herehow this IR Blaster works; a Android Phone with the custom made Android App sends the signal to Arduino circuit over Bluetooth, further the Arduino receives the signal through TSOP-IR receiver (1838T) and analyses it. Then Arduino commands the IR LED to blink in a particular pattern, corresponding to the button pressed on that Android Device App. This blinking pattern is captured by TV or Set-Top boxs IR receiver and it follows the instruction accordingly like changing the channel or increasing the volume.
But before that we need to decode the existing remotes. As mentioned earlier, in this project I have made use of two remotes, one which communicates with the TV while another is for the Set-top box connected to TV.

Circuit Diagram:

Decoding IR Remote Control Signals using Arduino:
The Arduino board here works in two phases, one is when you are using it to decode IR codes from remote and another is when you are using it as the IR blaster device.
Let us talk about the first phase. Now to decode the IR button codes, I have made use of Ken Shirriffs IRremote header file. This header file has many predefined examples/codes just to make it easier for us to work with IR codes:
  1. You first need to download and install the IR remote library from here https://github.com/z3t0/Arduino-IRremote.
  2. Unzip it, and place it in your Arduino Librariesfolder. Then rename the extracted folder to IRremote.
  3. Then burn the below provided code into Arduino, plug-in the custom shield as shown above and place a remote to be decoded in front of the TSOP IR receiver. Open up the serial monitor corresponding to this Arduino and press any desired button from the remote. Youll see some information displayed over the terminal, this information involves the type of code, its value and the amount of bits involved with it. Heres how it looks like:
#include <IRremote.h>
const int RECV_PIN = 6;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  irrecv.blink13(true);
}

void loop() {
  if (irrecv.decode(&results)) {
    if (results.decode_type == NEC) {
      Serial.print("NEC ");
    } else if (results.decode_type == SONY) {
      Serial.print("SONY ");
    } else if (results.decode_type == RC5) {
      Serial.print("RC5 ");
    } else if (results.decode_type == RC6) {
      Serial.print("RC6 ");
    } else if (results.decode_type == UNKNOWN) {
      Serial.print("UNKNOWN ");
    }
    Serial.print("  ");
    Serial.print(results.value, HEX);
    Serial.print("  ");
    Serial.println(results.bits);
    irrecv.resume(); // Receive the next value
  }
}
Once you are done with the desired decoding part, note down all the decode values and other information with their corresponding button name pressed.  This will serve as a database for the next phase of Arduino. The above program is taken from IRremote librarys examplesfolder, you can check out more examples to learn more about using the IR remote. So thats how we decoded the IR remote output. 
Now burn the Code, given in Code section at the end, onto this same board. Congratulations, you are done with the first half of this project.

Building the Android App for IR Blaster:
Here comes the second half, the Android App making. I simply prefer using MITs APP inventor-2 for making such kind of apps. If you are an amateur in Android coding, this will save your time and provide good results. The main components used in making of this app are not much, just few buttons and a Bluetooth client package. While coding the app, provide the corresponding text to be sent for each button pressed on the screen which would ask Arduino to blink IR LED in the same manner as it would have been done by the individual remote; also make sure that you provide the correct address of your Bluetooth HC-05 module. This is how the final App will look in your Android Smart Phone:
  

Here is the step by step process to build the app:
STEP 1:
Log on to this link: ai2.appinventor.mit.edu, or try and search out MIT appinventor-2 on Google. Signing-in to AI2 requires a Google account, so if you dont have, create one.

STEP 2:
Once you log-in with your Google account, youll be redirected to AI2 working webpage, which looks like this:

Start a new project by clicking Projectstab at the top and select Start New Project”. When you are done with the naming part and all, a blank screen will be displayed to you in which you can place buttons and text as shown above. This is the GUI screen, in which you decide how the app would look like to a user.
To use a button package, select Buttontab on the left side of the screen under User Interfacesection. Just drag any package from left-side menu and drop it onto the working screen. Similarly to display any text related stuff, make use of Labelpackage.

STEP 3:
After arranging all your buttons and labels, now its time to make a code for this app. But before that we need to select a Bluetooth package as well for communicating with the Arduino.
Youll notice that this package is not displayed on the screen rather it comes under Non-visible Components”. These are the components that have no significance in GUI make-up.

STEP 4:
Next comes the coding section, in which youll define the function for components that you have selected and you want to work with.
On the left side of screen youll notice all those packages that you have selected in the GUI section. The image above shows what all components are there in a particular package that you can make use of. Also notice that Bluetooth modules address needs to be provided in a textual format.

SETP 5:
When you feel that app is ready to be used and there are no errors as well, click on the Buildtab as shown above and select the second option. This will download your own created app, onto the computer, in “.apkformat. Then just transfer this .apk file to any Android device and click on it to install.

  Demo & Code


Universal IR Remote Control using Arduino and Android App Universal IR Remote Control using Arduino and Android App Reviewed by XXX on สิงหาคม 27, 2560 Rating: 5

ไม่มีความคิดเห็น