BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

[SOLVED] Blynk + IR SAMSUNG TV Remote Power ON/OFF

yessssssssss it worked, thanks costas, i’m just starting to share the project to which i will accredit to you. Many thanks

@Costas Costas solved this issue and here is everything you need to create a blynk app to turn ON/OFF your SAMSUNG TV’

Download IRremoteESP8266master Library from Github:-
[IRremoteESP8266

Here is the finished working Code

/*
  • IR](https://github.com/markszabo/IRremoteESP8266)remoteESP8266: IRsendGCDemo - demonstrates sending Global Cache-formatted IR codes with IRsend

  • An IR LED must be connected to ESP8266 pin 0.

  • Version 0.1 30 March, 2016

  • Based on Ken Shirriff’s IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com
    */

    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    #include <IRremoteESP8266.h>

    // You should get Auth Token in the Blynk App.
    // Go to the Project Settings (nut icon).
    char auth[] = “********************************”;

    // Your WiFi credentials.
    // Set password to “” for open networks.
    char ssid[] = “";
    char pass[] = "
    ”;
    char server[] = “************”;

    // Codes are in Global Cache format less the emitter ID and request ID. These codes can be found in GC’s Control Tower database.

    unsigned int Samsung_power_toggle[71] = {38000,1,1,170,170,20,63,20,63,20,63,20,20,20,20,20,20,20,20,20,20,20,63,20,63,20,63,20,20,20,20,20,20,20,20,20,20,20,20,20,63,20,20,20,20,20,20,20,20,20,20,20,20,20,63,20,20,20,63,20,63,20,63,20,63,20,63,20,63,20,1798};

    IRsend irsend(4); //an IR emitter led is connected to GPIO pin 4 (D2)
    void setup()
    {
    irsend.begin();
    Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
    Blynk.begin(auth, ssid, pass, server);
    // You can also specify server:
    //Blynk.begin(auth, ssid, pass, “blynk-cloud.com”, 8442);
    //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
    }
    BLYNK_WRITE(V1){
    int onoff = param.asInt();
    if(onoff == 1){
    irsend.sendGC(Samsung_power_toggle, 71);
    }
    }
    void loop() {
    Blynk.run();

    }
    }

Here is the QR Code for the simple PUSH button, (must be set to PUSH and not SWITCH

Hardware side:- I used a NODEMCU IR led connected to D2

OBVIOUSLY the IR LED must be pointing at the TV to work.

1 Like

Sory… i get this…
“error: ‘IRsend’ does not name a type”
I have all libraries installed…and just copy/paste the code from jasperdogJun

add the following 2 lines at the start, i will amend the code to reflect it above ok.

#include <IRsend.h>  // Needed if you want to send IR commands.
#include <IRrecv.h>  // Needed if you want to receive IR commands.

here is the revised code due to the IR library being amended some time ago.

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>  // Needed if you want to send IR commands.
#include <IRrecv.h>  // Needed if you want to receive IR commands.



// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "********************************";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "**********";
char pass[] = "**********";
char server[] = "************";

// Codes are in Global Cache format less the emitter ID and request ID. These codes can be found in GC's Control Tower database.

unsigned int Samsung_power_toggle[71] = {38000,1,1,170,170,20,63,20,63,20,63,20,20,20,20,20,20,20,20,20,20,20,63,20,63,20,63,20,20,20,20,20,20,20,20,20,20,20,20,20,63,20,20,20,20,20,20,20,20,20,20,20,20,20,63,20,20,20,63,20,63,20,63,20,63,20,63,20,63,20,1798};

IRsend irsend(4); //an IR emitter led is connected to GPIO pin 4 (D2)
void setup()
{
  irsend.begin();
  Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
  Blynk.begin(auth, ssid, pass, server);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
}
BLYNK_WRITE(V1){
  int onoff = param.asInt();
  if(onoff == 1){
    irsend.sendGC(Samsung_power_toggle, 71);
 }
}
    void loop() {
     Blynk.run();
  
}

not working… sorry…

C:\Users\Juanjo\Documents\Arduino\sketch_jun30e\sketch_jun30e.ino: In function 'void BlynkWidgetWrite1(BlynkReq&, const BlynkParam&)':

sketch_jun30e:34: error: no matching function for call to 'IRsend::sendGC(unsigned int [71], int)'

     irsend.sendGC(Samsung_power_toggle, 71);

                                           ^

C:\Users\Juanjo\Documents\Arduino\sketch_jun30e\sketch_jun30e.ino:34:43: note: candidate is:

In file included from C:\Users\Juanjo\Documents\Arduino\sketch_jun30e\sketch_jun30e.ino:4:0:

C:\Users\Juanjo\Documents\Arduino\libraries\IRremoteESP8266\src/IRsend.h:181:8: note: void IRsend::sendGC(uint16_t*, uint16_t)

   void sendGC(uint16_t buf[], uint16_t len);

        ^

C:\Users\Juanjo\Documents\Arduino\libraries\IRremoteESP8266\src/IRsend.h:181:8: note:   no known conversion for argument 1 from 'unsigned int [71]' to 'uint16_t* {aka short unsigned int*}'

C:\Users\Juanjo\Documents\Arduino\sketch_jun30e\sketch_jun30e.ino: At global scope:

sketch_jun30e:41: error: expected declaration before '}' token

 }

 ^

exit status 1
no matching function for call to 'IRsend::sendGC(unsigned int [71], int)'

i don’t know, it works perfectly for me as per the code.

OK, thanks anyway…i will keep trying!

i remember using a different approach to this, i’ll try and find my sketch and post it for you to try.

1 Like

try this code, obviously change the gpio pin number for the esp8266 board you are using
in this line IRsend irsend(2); //an IR emitter led is connected to GPIO pin 2 (2)

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>  // Needed if you want to send IR commands.
#include <IRrecv.h>  // Needed if you want to receive IR commands.


char auth[] = "your token";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "*************";
char pass[] = "*************";

IRsend irsend(2); //an IR emitter led is connected to GPIO pin 2 (2)
void setup()
{
  irsend.begin();
  Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
  Blynk.begin(auth, ssid, pass);
  
}
BLYNK_WRITE(V1){
  int onoff = param.asInt();
  if(onoff == 1){
    irsend.sendSAMSUNG(0XE0E040BF, 32); // 32 bits, no repeat

}

}
void loop() {
  Blynk.run();
    
}

i take it you are not using your own local server? if you are using your own local server then you need to add some more information to the code,

It work!!
Im using global blynk server.
If i want to use my ir code, how i replace :
irsend.sendSAMSUNG(0XE0E040BF, 32); // 32 bits, no repeat

IR code is this:
unsigned int unknown[23] = {1250,450, 1250,400, 450,1200, 1300,400, 1250,400, 450,1250, 400,1250, 450,1200, 450,1250, 400,1250, 450,1250, 1250}; // UNKNOWN A32AB931 32 bit

that explains why you couldn’t use the original code which was for using a local server.

is it a samsung tv? because if it is then go back to using the original code without the server added code.

Im trying to send IR codes to a Samsung TV, SONY muteki and a Peabody Heater(thats the “unknown” code) using blynk… only to control them with Google Assistant (thanks to IFTTT), i think i use multiple blynk virtual ports (V1 for TV power… and so…)

here is the original code less the local server bit.

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>  // Needed if you want to send IR commands.
#include <IRrecv.h>  // Needed if you want to receive IR commands.



// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "********************************";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "**********";
char pass[] = "**********";


// Codes are in Global Cache format less the emitter ID and request ID. These codes can be found in GC's Control Tower database.

unsigned int Samsung_power_toggle[71] = {38000,1,1,170,170,20,63,20,63,20,63,20,20,20,20,20,20,20,20,20,20,20,63,20,63,20,63,20,20,20,20,20,20,20,20,20,20,20,20,20,63,20,20,20,20,20,20,20,20,20,20,20,20,20,63,20,20,20,63,20,63,20,63,20,63,20,63,20,63,20,1798};

IRsend irsend(2); //an IR emitter led is connected to GPIO pin 2 (2)
void setup()
{
  irsend.begin();
  Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
 /Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
}
BLYNK_WRITE(V1){
  int onoff = param.asInt();
  if(onoff == 1){
    irsend.sendGC(Samsung_power_toggle, 71);
 }
}
    void loop() {
     Blynk.run();
  
}

same error… something with “irsend.sendGC” comand…

the following turns my samsung tv on/off

unsigned int Samsung_power_toggle[71] = {38000,1,1,170,170,20,63,20,63,20,63,20,20,20,20,20,20,20,20,20,20,20,63,20,63,20,63,20,20,20,20,20,20,20,20,20,20,20,20,20,63,20,20,20,20,20,20,20,20,20,20,20,20,20,63,20,20,20,63,20,63,20,63,20,63,20,63,20,63,20,1798};

just remember to set the blynk button in th blynk app to a push and not switch

1 Like

A post was split to a new topic: I want to create a button to press eeprom function for 3 times eeprom, and 3 buttons to send IR