Using the NodeMCU with the Arduino IDE we can have a simple infrared device in SmartThings. I am using TSAL6100 and TSAL6400 high quality LEDs. The NodeMCU can have either 2 or 3 IR LEDs connected to it in series.
If using 2 IR LEDs, feel free to use the IRremoteESP8266 code sample. In that folder, you will also find wiring pictures for reference. For longer distance like 11-12 feet, I had to remove even the lowest resistor I had which was 27ohms. So no resistor for this wiring technique otherwise the IR distance goes down to 9-10 feet.
For wiring 3 IR LEDs for higher output and using 5 volts. As of IRremoteESP8266 version 2.0 (around July 1st of 2017), the authors of the library granted my feature request and now the signal can be REVERSED and the ground signal will be sent to the pin rather than VCC as done if using 3.3v and as the original library 1.x did. The authors did a great job implementing my feature request. So now, simply change the sendGround variable at the top of the Arduino sketch to change what gets sent to the IR connected pin. That also means that you have to directly connect the positive side of the LEDs to the USB cable’s positive lead and the negative side to the ESP8266 pin so reversed from the wiring of the 2 LED example above. With this wiring technique, I successfully used a 27ohm resistor (or no resistor) and distance didn’t suffer. This was a really powerful signal that didn’t need 100% line-of-sight like the slightly weaker 2 LED layout.
Here is the SmartThings device code for a TVDevice. The only bug I have with it is the fact that Alexa/Echo does not like it when I say “Alexa set the TV Remote to 4” and it should switch to HDMI input #4. This for some reason does not work and I hope somebody smart can help me in fixing that. Dimmers work well with this Alexa/ST range ability but my device for some reason does not. On/off works very well via Alexa. UPDATE: Thanks to @lonelygadget and the recommendation to add the word Light. Now “Alexa set TV remote LIGHT to X%” works great but lately Amazon fixed that word light requirement and now my older Alexa attempts work as well. I have mine set to change TV inputs when setting to zero then you can say “Alexa set the TV remote UP” or “Alexa set the TV remote to 25,50,75 or 100” cycles through my external HDMI input box.
Thanks to my buddy @Casper for posting his IR capable device which got me started with ESP8266/NodeMCU and IR — I haven’t stopped since This would have been totally foreign to me if he didn’t post his amazingly detailed write-up of his fan IR hack. Before he posted, I have never even used Arduino even as a pro computer nerd of 23 years. I like Linux and used my familiar Raspberry Pi for my GPIO triggering needs like in my other project for triggering relays/garage/gate. The wireless NodeMCU changes the game and comes at a lovely $5 price and no OS to maintain like in the RPi.
Library of many IR code sequences: