All Remotes Into Your Smartphone

11K14934

Intro: All Remotes Into Your Smartphone

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.

33 Comments

A great project... but try to verify the sketch and keep getting this message.. Using a V3 LoLin Esp8266 anyones help would be greatly appreciated.. Thanks

compilation terminated.
exit status 1
Error compiling for board Generic ESP8266 Module.
hola, podrías compartir el código QR del proyecto blynk, esto con el fin de tener una idea de como creaste todos los botones. muchas gracias
EllisB1 i dont understand this part of your code. What's function 1 and function 2 for? I guess that function2 is for when the user selected the TV living room the buttons color will be change. Those who are not needed will became red. I am right?
What is char server[]? How can i have blynk cloud server? Is blynk cloud server is required in your code?

excuse me mister, do you have any idea to share in order to make your suggestion be possible?

honestly is something I never toke in consideration.
On product prospective is something can be build. This feature is super
interesting if you want move on production level where you need to keep thinks
simple for your user. Please consider that this project was developed per my
own home and not on commercial level.

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.

i found your project very interesting and i want to do that. can i ask you a question? are you using an ordinary tv or a tv that you can connect to the internet via wifi? 'cause if were gonna do that, we only have an ordinary tv that cannot connect to the internet.

hope for your response :) Thank You!

Ordinary TV. Tv isn't connected to internet.
You need an Internet connection with WIFI to send instruction from your smartphone to the NodeMCU (the board I used for this project).

Best

where i will put the device(NodeMCU)?

this is strictly connected to where the device are.. please consider 3 facts:

- IR sensor is connected NodeMcu via dupont jumper ( 20 cm long)

- IR sensor have "to see" the IR receiver on tv/dvd/...

- you need access to electricity to empowering the Nodemcu board.

did you used an "ir sender/transmitter"? because what you required above is just an "ir led". ir led is only to indicate that you pressed something in the remote and it cannot send the commands to the ir receiver of the appliances.

please answer me. Just badly needed. Thank you in advance :)

Can i control the appliances even I'm not in my home? or my smartphone and the Board must be in the same Wi-fi Network.

By the way, i started to search the node MCU board in ebay and there's a lot of MCU board appeared. which one i will purchase? please help me. Thank you!

This solution works via internet. you can be (as said in the tutorial) everywhere in the world and control your device.

Regarding board see my comment above..... Please consider that you need some experience in coding and DIY project to create this... Isn't a super entry level project :-)

yes that is ok. Is the version 2 of node MCU. Please select NodeMCU 1.0 in Arduino IDE board selector.

Hello again! I was trying to make this project work for me months ago but I couldn't figure it out. Summer is here and I decided to look at the codes again.

This was a part of my code:

BLYNK_WRITE(V0)
{
if ( pinValueV0 == 1 )
{ irsend.sendSAMSUNG(0xB24D3FC0, 32);
} else {
}
}

I realised that I am not checking any parameter from Blynk mobile app. Blynk parameter isn't transferred to the variable. So I changed it this way.

BLYNK_WRITE(V0)
{
if ( param.asInt() == 1 )
{ irsend.sendSAMSUNG(0xB24D3FC0, 32);
} else {
}
}

I changed the IR led with a regular led and tried it. I saw that it blinks for a second every time I push the button no matter how long I keep the button pressed on in the app. Just like it should happen. Nice!

I changed the led with the IR led and checked it with a camera and it blinked again.

But AC didn't respond. I brought the breadboard just next to the AC in case led blink was not bright enough but it didn't work again.

This time I did it right I guess. But it didn't work. Any ideas?

Yes, you can easily control also air conditioner because they usually use infra red remote. The procedure is exactly the same.

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.

More Comments