Introduction: All Remotes Into Your Smartphone

About: I'm 37 years old and I'm living in Italy. I'm COO Zodiak Advertising (a company doing on line advertising). I live with my wife my my 2 kids: a little boy called Mattia and my pet/kid Irma :-). I'm passionate …

Every time I'm trying to watch a TV program or listening some music I don't found the appropriate remote control.

In my living room I got many device: a Tv, a DVD player, an HiFi, a projector with its own screen....

Every device have its own remote that usually is lost in the sofa or in my kid toys basket...

I implemented thanks to Blynk, a NodeMcu board, some IR led and jumpers an App into my smartphone to pilot al device in the living room via IR.

You can read this article in Italian (my native language) in my blog; the original title is:comandare con il cellulare la tv. ;-)

If you like my project please supporting me voting it in Microcontroller contest (you have to click on top right Vote! icon) Thankyou. Contest will close at May 1st 2017.

Step 1: Step 1: Needed Things

to do this project you need:

- A NodeMcu board. I usually buy it on ebay.. In this project I used the version 3 from Lion (officially still a V2).

- Blynk to create the user interface and to manage the connection between the nodemcu and the smartphone.

- Jumpers cable

- IR led to send the ir signals.

- a TSOP4838 to read IR codes form the remotes.

Total cost: around 15 dollar.

Time for the implementation: around 1 hour.

Step 2: Step 2: How Does It Works?

First think we have to do is select device that we want embed in our project and copying their codes. Please consider that if you want run this project with one board only all the device must be placed in the same room.

How does remote control works?

Every button in a remote control send via IR (infra red) a unique code based on a certain protocol into the air. Only the parent device is able to read this code in the proper way (decoding) and do something like increase the volume on the TV.

In this instructionables we will copy and store those codes into a Nodemcu.

With our smartphone and Blynk we will be able to command Nodemcu to send proper IR command.

Step 3: Step 3: Reading Codes From Remote

If you are using the NodeMcu board that you need the ESP8266 IR library to grab codes.

First you have to download the IR library for ESP8266.

This library is specific for this hardware. https://github.com/sebastienwarin/IRremoteESP8266

Once installed please look in the example the file IRrecvDumpV2.ino and upload it into the board.

Now you have to take care of hardware connections on your board. Connect pins to a IR RECEIVER, 38KHZ. I bought on Ebay a TSOP4838(is a ; it's pretty cheap.

If you are using a TSOP4838 you have to connect:

TSOP4838 Nodemcu

Pin1 to DATA ---> GPIO pin 2 --> D4 ON NODE MCU

Pin2 to Ground ---> GND

Pin3 to VCC ---> 3V3

Give power to NodeMcu board via USB. Every time you will click a button on remote the coding structure will be displayed on Arduino IDE serial monitor. Look at the picture if you want see an example of coding structure.

Copy and paste all remote button code. Click one time on each button you want replicate and copy the full code in a document. Please copy every time the full code.

Sometime the script isn't able to recognize the protocol and you have to put raw code. The used library is actually covering many remote but not 100%. if you are lucky and the code has been recognized you can copy just this part otherwise you have to use the raw code.

There are tons of instructables already available that shows how to read codes from remote; please google it if you need extra support.

Step 4: Step4: Design Your Remote on Smartphone

Ok, this step is quite personal.. Design reflect your home devices and your needs.

Based on my experience:

design always a device selector menu. You will use it to select the right remote and save space on your smartphone user interface. Thanks to this selector and some extra code you will be in the position to use for example the same ON/OFF button across all device instead of set up many button with the same logic.

Design it on the paper; make test and test:

You have to think about your remote deeply. You have to figure out different situation and think open mind.

I designed around 10 times the remote before the final release.

To give you some ideas... the one you are seeing in the picture is my own remote.

On top you can see +/- buttons and < / > buttons.

Those buttons are cross device. They are very common and they have different purpose based on the device.

Ex: +/- in TV means more / less audio in projector screen go up/go down.

On/off are cross device

In second line you can also find differnt logical button like source/exit/ok...

Sometime button are making the same think also if a different device is selected. In my case for example DVD player is quite important so those button doesn't reflect the device selection.

Buttons are deisgned based on Blynk. I used the button widget: here how does they work. All buttons are Virtual.

Step 5: Step 5: the Sketch

This is the hardest part of the job. 

We have to write a code that will basically connect the smatphone (via Blynk) to you NodeMcu where the IR sensor are placed.

This code reflect the design of your remote in step 4. I can only help you giving a copy (in download) of my code.

My code is working with my devices and is based on my needs.

The code have comment to been easily adapted.

Just a smal summary:

1. At the beginning of code we have several library inclusion (#include) all those library are mandatory.

2. The aut code: is your own unique code in Blynk environment. Your code has been sent by Blynk by email when you are set up the project on your mobile.

char auth[] = "XXXXX";

3. Simple timer is a command that avoid the KO of my small NodeMCU. this command isn't mandatory. You have to add if you are making color changes on button. Color changes use lot of memory and you haven't do you it massively (maximum 3 and a small pause)... basically is similar to a delay command. Don't use delay command as they generate problem in Blynk enviroment.

4- IRsend irsend(0); ///an IR led is connected to GPIO --> D4

This is the core command of all sketch. I'm sayng to the board that pin4 will be used to send infra red.

5. void mySetProperty Those functions are to manage colors in the user interface. basically I'm changing colors based on the device that i'm using. this code part use lot of memory. I introduced functions to avoid NodeMcu KO. As explained before this part of the code use memory massively and you can't add many lines at the same time. This part of the code is for user interface purpose. Helps user to understand what remote they are using. Isn't mandatory on code prospective. If you have just 1 remote avoid this part of the code. Isn't necessary.

void mySetPropertyFunction1notneeded(){<br>  Blynk.setProperty(V2, "color", "#23C48E"); //GREEN
  Blynk.setProperty(V4, "color", "#23C48E"); //GREEN
  Blynk.setProperty(V5, "color", "#23C48E"); //GREEN
  Blynk.setProperty(V6, "color", "#23C48E"); //GREEN
}

6. - Case structure / Device selection. This part of the code is not mandatory. Is an if case that give a value to the variable called pinValueV1. I will use this value (is an int) in the next if clausole. If you have just one remote control you don't need this part of the code (obviously you have to adapt the second IF)

Basically I select TV ValueV1=1; if DVD ValueV1=2 and so on...

In the code you can also see some color set up. those color set up (I did it to reduced the color functions....sorry if isn't very clear as code)

BLYNK_WRITE(V1) {<br>  switch (param.asInt())
  {
    case 1:               // Item 1 - TV LIVING
      pinValueV1 = 1;
      Blynk.setProperty(V2, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V4, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V5, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V6, "color", "#23C48E"); //GREEN
       testingTimer.setTimeout(300,mySetPropertyFunction1); // perform the second function 400ms later
      break;
    case 2:               // Item 2 - DVD
      pinValueV1 = 2;
      Blynk.setProperty(V2, "color", "#D3435C"); //RED POWER
      Blynk.setProperty(V3, "color", "#D3435C"); //RED SOURCE
      Blynk.setProperty(V3, "label", "HOME");
      Blynk.setProperty(V4, "color", "#D3435C"); //RED SOURCE
      testingTimer.setTimeout(300,mySetPropertyFunction2); // perform the second function 400ms later 
      break;
    case 3:               // Item 3 - AUX
      pinValueV1 = 3;
      Blynk.setProperty(V2, "color", "#04C0F8"); //BLU
      Blynk.setProperty(V4, "color", "#04C0F8"); //BLU
      delay(1000);
      break;
    case 4:
      pinValueV1 = 4;
      
      break;
    case 5:             // Item 5 - Projector Screen
      pinValueV1 = 5;
      Blynk.setProperty(V15, "color", "#ED9D00"); //YELLOW
      
      break;
  }
}

This part of the code is a routine, you have to do it for every button. +/- are a little bit different in terms of coding but logic is quite easy.

7. Now I'm going to send command to every single button in the smatphone

you have to adapt it to your device; in this case is a NEC coding. where (for ON) I send che command FB38C7 in 32 bits if on device selector 1 is selected (TV) or the code B4B40CF3 in 32 bits based on SAMSUNG coding if 2 (DVD) is selected at device selector level. And so on....

BLYNK_WRITE(V2) // ON/OFF<br>{
  if ( param.asInt() && pinValueV1 == 1 )  // ON/OFF TV
  { irsend.sendNEC(0xFB38C7, 32);
  } else if ( param.asInt()   && pinValueV1 == 2 ) // ON/OFF DVD
  { irsend.sendSAMSUNG(0xB4B40CF3, 32);
  } else if ( param.asInt()   && pinValueV1 == 3 ) // ON/OFF AUX
  { irsend.sendNEC(0x7E8154AB, 32);
  }
}

8. Finally the sketch loops.

// ========LOOP<br>void setup()
{
  Serial.begin(115200);
  Serial.println();
  Serial.println(F("Started"));
  irsend.begin();
   Blynk.begin(auth, ssid, pass, server); 
  Blynk.syncAll();
  
}
void loop()
{
  Blynk.run();
  testingTimer.run();
}

Step 6: Step 6: Hardware (wire) Connection

Ok, finally we have to connect some wire and check the correct set up of our system.

FYI: Some of my device are located inside a drawer (the HiFi and DVD). I used a breadboard to help me in wire connection and to fork IR signal. If all your device are closer you don't need it (one IR led is enough).

IR led connection to nodemcu is super simple you need just 2 cables:

IR LED NODEMCU

the longest (+) ---> Pin GPIO 0 --> D4 (output/data)

the shorter (-) ---> GND (ground)

Step 7: Step 7: Enjoy!

Ok, now we ready to test the project.

Give power to the nodemcu and waiting for few seconds. The nodemcu board will be connected to your wifi.

Please open the Blynk app on your smartphone to open your new remote control for all your devices.

Pelase watch the video to see how the project works

Enjoy!

If you like my project please supporting me voting it in Microcontroller contest (you have to click on top right Vote! icon) Thankyou. Contest will close at May 1st 2017.

Microcontroller Contest 2017

Participated in the
Microcontroller Contest 2017