ESP8266 / NodeMCU / Arduino based TV Remote

Have you experienced one remote sending 2 different set of protocols? I’m getting NEC for power but volume is registering RC5.

Not really but my guess is that it can happen with cheaper alternatives in the market and IR standards being old/accepted/merged, etc. The key question is whether you SENDING the IR signal works, and if it does, then obviously the original IR read went well :slight_smile:

So embarrassed, rookie mistake, darned remote had 2 volume buttons! :scream::blush::grin:

Thank you and @Casper for the examples! I’m now able to control my receiver and projector using the device type, parts list, and writeups. This is perfect now that the previous app I was using is no longer supported. Needs some testing Alexa testing but I think the hard part is over.

Our pleasure! @Casper made the introduction easy for me and I’m thankful to him as well!

So do you guys have this working now (Alexa or app)? Can you learn remote command then play them back on time schedule? I got a cheap iLife robot vacuum that has limited programming (daily or manual), I’d like to start it via a more complicated schedule.

Of course it’s working, why else would there be a project post here with folks discussing it… Alexa works too for on and off and it can understand a slider value too but for Alexa you’ll have to say the keyword “light” after the device name to set it to some slider value — like I use for my HDMI inputs.

For scheduling, use SmartLighting (by Samsung ST but slightly limited in features but fully supported) then there’s the way better CoRE (Community’s Own Rule Engine) which are both great for complicated rules & automations which you’re talking about.

Are there instructions on how to install this? I get error 302 when trying to upload the sketch to my ESP8266 node MCU 1.0

See @Casper’s post for a nice explanation of how to start. It’s also linked in the first post.

Hi JZst,

Im using a ESP8266 board and Arduino IDE 1.8.1 to upload your sketch. The hardware im using for the IR Transmitter is the following IR KIT from Casper’s write up. I loaded up your sketch (TV Device Sample v1.0.20160806) and i am seeing that D2 and D4 needs to be declared in the sketch, do you know what exactly i should be adding? Also i have a samsung TV and have the hex codes for the commands i would like to implement, is it as simple as just replacing your codes with the hex codes? sorry for all the questions but kinda new to this :slight_smile:

thanks for your help in advance

@Casper’s instructions are much clearer and more complete than mine. I would actually suggest using his sketch and succeeding at that first with a single sending of IR then moving onto mine.

There are not 2 dispensations for a pin, just one closer to the top of the script… just search for D2 and you should only find one. Don’t worry about D0 or D4 that you see in my code sample… that just turns off the blue and red LED’s on the NodeMCU, nothing more.

Connect your IR LED’s to D2 in series per my wiring diagrams. Decide whether to send HIGH or LOW to the pin — meaning pick if you want to use 2 LED’s or 3… for 2 you can get away with the standard IR library using 3.3 volts. If you want 3 then you need to use the alternative IR library that I provide and turn the LED’s around as it will be sending 5 volts… basically connect their negative/cathode to the D2 pin and the anode end directly to positive/VCC.

Now the actual IR sequence that needs to be sent is likely NOT what’s already in my sample sketch. You have to replace those with your TV brand and signals — unless you use an LG TV for which power and volume should work from my sketch. So, how does one get/read your signal — that’s where you follow @Casper’s notions of using the IR “reader” that came in your kit and his “IRReceiver” sketch and open up the serial monitor in the IDE. Then press your desired remote signal for the receiver to give you the exact sequence you need. Once you have that, just replace one of my commands in the handleIr() method.

Good luck… the key is to read in one of your device sequences and then send it with my sample. Make sure to just use the web-page, and for now take SmartThings out of the equation until you got it figured out.

great thanks, i will follow that. but even just loading your sketch i get the following: is that normal

Arduino: 1.8.1 (Windows 10), Board: “Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS), ck, Disabled, None”

IR_TV_REV1:26: error: ‘D2’ was not declared in this scope

IRsend irsend(D2);

           ^

C:\Users\raymond.lopez\Documents\Arduino\Sketches\IR_TV\IR_TV_REV1\IR_TV_REV1.ino: In function ‘void setup()’:

IR_TV_REV1:135: error: ‘D4’ was not declared in this scope

pinMode(D4, OUTPUT); //GPIO2 also D4

       ^

exit status 1
’D2’ was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

No not okay just tried and I get the same error… likely the reason why failing. Use NodeMCU 1.0 (ESP8266-12E) as your board. Also make sure under IDE>Preferences to have this additional board manager URL: http://arduino.esp8266.com/versions/2.3.0/package_esp8266com_index.json

I updated to IDE 1.8.1 and all of my junk still works right. Definitely change the board type…

great that worked. i have the IRrecvDumpv2 uploaded to the nodemcu and the ir receiver on gpio 2. when i send infrared cmds from the remote to the receiver i do not see anything happening on the serial monitor. i switched to almost all the baud rates to see if that was the issue. but no luck. any idea? thanks

Weird, these pieces exist in the IRrecvDumpv2 sketch and they are enough to give you some output… try adding to the loop a Serial.print(“test-”);Serial.println(millis()); — to see if it gives you what you expect, which is the up-time of device.

void  setup () {
  Serial.begin(9600);   // Status message will be sent to PC at 9600 baud

void  loop ( ) {
    Serial.println("");           // Blank line between entries

where do i add those lines in the sketch? am i commenting out the existing loop ?

Right at the top of the loop — then serial monitor should spit out the milliseconds that the ESP8266 has been up.

like this? im getting the following exit status 1 - redefinition of ‘void setup()’ when compiling

//+=============================================================================
// The repeating section of the code
//

void  setup () {
  Serial.begin(9600);   // Status message will be sent to PC at 9600 baud

void  loop ( ) {
    Serial.println("");           // Blank line between entries

void  loop ( )
{
  decode_results  results;        // Somewhere to store the results

  if (irrecv.decode(&results)) {  // Grab an IR code
    dumpInfo(&results);           // Output the results
    dumpRaw(&results);            // Output the results in RAW format
    dumpCode(&results);           // Output the results as source code
    Serial.println("");           // Blank line between entries
    irrecv.resume();              // Prepare for the next value
  }
}

I’m guessing you don’t write that much code :slight_smile: as some of cardinal rules are broken. You cannot re-define functions/methods… I just gave you loop() and setup() just to show you THE SECTION where you should inject the code but don’t create a new loop/setup method.

You also didn’t close the setup() function with a curly brace. Here’s a fixed example:

void  setup () {
  Serial.begin(9600);   // Status message will be sent to PC at 9600 baud
} // DON'T FORGET TO CLOSE FUNCTIONS


void  loop ( )
{
    // AT THE TOP OF THE LOOP ADD YOUR DEBUG TRACES
    Serial.print("test-"); Serial.println(millis())

  decode_results  results;        // Somewhere to store the results

  if (irrecv.decode(&results)) {  // Grab an IR code
    dumpInfo(&results);           // Output the results
    dumpRaw(&results);            // Output the results in RAW format
    dumpCode(&results);           // Output the results as source code
    Serial.println("");           // Blank line between entries
    irrecv.resume();              // Prepare for the next value
  }
}

yeah sorry i do not write much code at all, not my thing obviously lol. but i copied your code and getting the same error