Make a "dumb" fan "smart" using cheapo ESP8266 board controllable via ST (universal IR remote)

Wow those are very useful resources you got there, thanks a lot for doing research on this. Honestly, all I do with the IR remote is just to switch them on and off via ST widget or Alexa, I don’t even have TV box or cable, just a Chromecast haha, so no need to switch channel or anything.

On my Samsung TV, I’m actually still using LIRC on a RPi box, so didn’t really test the Arduino IR. But for a smaller Emerson TV, both sendNEC and sendRAW worked.

I checked out the IRLib, looks very nice, but I’m too lazy to try since I can do pretty much anything I need with current library, still I would love to hear from you when you have a chance to try it.

Also please let me know if the TSAL6100 IR LED works, for now what I’m doing is placing multiple modules in front of the devices I want to control, costly but works :smile:

I have a question, have you tried the 5V Vin (Voltage IN) pin on bottom left side? Looks like you can feed the ESP directly via the USB cut cable and not through the micro USB port. It works perfectly since I burn-in tested it yesterday for a while! This means we can serially connect TWO (or more) high output IR LED’s like the US one I bought of the TSAL6400 model. Chinese shipping makes me impatient :slight_smile:

But going back to where Chinese shipping is worth it… amazing what you can do with $5 of hardware. I have 2 NodeMCU in hand and 2 in the mail :slight_smile: Thanks for the eye-opening experience with this board, @Casper!

That’s awesome, I actually never tried anything with that 5V pin yet.

To fight with the short range IR, I actually ordered 5 of them from Ebay ($5 each) and now 2 TVs and the fan get the own Nodemcu module :smiley:

They’re indeed very cheap from China, but you’ll never know how long they’ll last :smile:

Wow even the cheaper TSAL6100’s that finally came in from China are working GREAT. I first started with using MicroUSB which steps down the 5v to 3.3v. I am using 2 serially wired IR LED’s per the MANY articles that I read. When I used a 100ohm resistor, it increased my IR distance from 3ft to like 5-6ft on the TV & DirecTV box. My HDMI switcher distance also doubled the distance from like a foot to 2 feet, still unacceptable. As soon as I took the 100ohm resistor out, the thing now works from the wall directly opposite of all of this equipment.

So, NOT using the 5v pin and using 2 TSAL6100 IR LED’s = magic :slight_smile:

Just to “attempt” to do the math… 3.3v - 2(1.2v LED) = 0.9 volts and we want like 25milliamps so 0.9 / 0.025 = 36ohm resistor. However, whenever I tried 22ohms or 47ohms, I had to be a couple of feet away from the back wall. Only with zero resistance I was able to do the full room away. My guess is the LED’s are going to get fried over time but it should be a really long time since the usage/on-state is so minuscule.

All the best!

That sounds great :smiley: , I got lazy and bought the pre-built IR module instead. It’d be way better if you can built your own IR transmitter, which you have nicely done :slight_smile:

How’s the software side going? Any updates with the device type? I wonder if we can make Alexa to trigger the custom switches yet.

If you’re around my hood, feel free to pick some up :slight_smile: I got 20 of them… The pre-built READER is actually pretty decent but the blaster is terrible. Sadly I got 3 of those sets too due to impulses :slight_smile: at least I can use the receiver — it’s really sensitive.

See my last post on the RPi thread… I updated the code a few days ago with full ESP8266 support.

I updated the ST Groovy code to easily interface with ESP8266 and I provide the same Arduino sketch for 2 relays not IR stuff just yet. Alexa can trigger ON/OFF or you can assign ON to momentarily trigger your main switch while OFF can momentarily trigger the custom one. It works very similarly to the Raspberry Pi. I want to also release my attempt at a TV remote but I’ll be asking for some help from the community as I’m having issues doing something like “Alexa set my TV Remote to 2” using a slider — the same way that I can do with dimmers. I got close and the ST front-end works but Alexa is being a prude and don’t wanna put out :slight_smile:

Relays were simple enough to do with the tiny NodeMCU board. However, I liked how compact the DUAL 5V relay was as I’m trying to fit into a project box. The little 3.3v relays are kinda long and not on a single board like the. This made it PERFECT for me to test my 5V pin on the ESP8266. Everything worked great but I had to connect the relay positive directly to the 5V line. That means I had to connect the relay itself to any GPIO pin but instead of sending a positive signal, I had to send a negative/ground. It worked great and I am now waiting for a Chinese clear project box to finish up the Garage/light project.

HOWEVER, what that made me realize is that I cannot do the same thing with IR LED’s. Considering that we call a library function which uses “standard” functions unlike my 5V relay POC, and uses a POSITIVE signal to send to the IR LED while the negative lead is always connected. So in order to truly use the 5V feed, I’d have to find where in the IRLib the pin is sent a HIGH and change it to LOW and repeat for the other. Only then we can use 5V — but what’s the point when 2 high output IR LED’s are AWESOME with no resistor and I can easily do 11-12 foot distance. Once I put that in a project box, I will bend the LED’s to point to the two device areas I need to cover.

3 Likes

After some more boards came in and I have IR LED’s to test with (using TSAL6100 — 3 of them) I successfully reversed the signal to be NEGATIVE not positive as designed by default with the IRremoteESP8266 library.

I basically copied that library folder and renamed it to IRremoteESP8266at5V. I then renamed the CPP and H file to the new name, then changed library.json and library.properties content. I then modified the CPP lines 336, 338 and 347 to be the opposite, so LOW became HIGH and HIGH became LOW.

I modified the included library name in my Arduino sketch to use the newly created library, built and deployed and voila, I can power 3 IR LEDs in series. The positive side being directly connected to the USB supplied 5V and the negative side of the LED connected to the pin defined in the Arduino sketch. Looks like we can get some powerful signal now. I could swear it doesn’t require 100% line-of-sight and you can be a few inches below (trying to mount to lower bed post rather than the wall) at 11-12 foot distance as I mentioned.

I’m really impressed with the IR functions. You’ve created a monster @Casper :slight_smile:

Once I’m ready I’ll post some sample code like you did as I’m sure there’s somebody out there smarter than me that can help with the Alexa ability to say “Alexa set my TV remote to 4” and that changes a dimmer/value in ST thus change to HDMI4 — just like other dimmers allow in Alexa/ST integration. Unfortunately, Alexa does the few beeps and turns off every time she hears that phrase, while on & off commands work very well of course.

Keep in mind that (per ST forum posts) you can only have a maximum of 100 same capability devices so TV volume and TV channels will each be a device since I want Alexa to use ON for channel/volume up and OFF for down, etc.

Wow @JZst you’re the man :smiley:

I can’t imagine you’d dig this deep haha, I feel so horrible that I never done more research and instead bought several modules for place them near each of my devices… :sweat_smile:

Anyway since you’ve already done the hard work, I’ll just wait until you release the goods… also please post some photos on the new IR led you made.

What I still haven’t tested with your Wifi device type is can I create 2 device types pointing to 1 server? This is for Alexa to trigger other functions of the device I want to control (cannot make Alexa to control custom triggers).

I was looking into the slider to work with Alexa as well but still no luck.

Done @Casper! You did me a huge favor by documenting this and I made sure to repay that favor. Check out my new TVDevice which comes with two wiring/code samples. One is using standard IRremoteESP8266 library and 2 IR LEDs with standard wiring like your project where the positive signal is sent to the pin. The other code sample is my slight modification to the IRremoteESP8266 library and the Arduino code which is basically a copy of the 2 LED sample but the library/include reference is what changed. Enjoy and let me know if you have any questions.

https://community.smartthings.com/t/esp8266-nodemcu-arduino-based-tv-remote/50161

1 Like

Hi,
I apologize if this is covered in this thread, I’ve got one foot out the door, but is there a way for this device to ‘learn’ the codes from an existing remote? I’ve got a set of no-name Chinese deck lights with RGB leds that are controlled by remote, and I doubt I’ll find anything written about the ir commands, and certainly don’t think I’ll find it in a database.

Thanks - Bob S

Yes, that’s exactly this project is doing: get IR code from any remote and save it as firmware.

The hard part is you have to record the IR code using an IR receiver manually on Arduino IDE (if you know how the IDE works then it’s a piece of cake)

Awesome, thanks! I messed around with Arduino last year making a track timer for my grandson’s Pinewood Derby test track… it wasn’t always pretty, but I got through it. Thanks again!

No problem, there will be confusion if you attempt to make 1 of these, do let me know to avoid spending time debugging it.

Ok, I found the reason, I was looking at this example code, when I’m using your version of the main sketch then it work perfectly!

Btw, the Fan on/off code is almost universal I guess, it work with my 2 different brand fans :slight_smile:

One more things, for beginner like me, I was expecting to “see” the big LED to blink when I trigger it, I forgot they are infra-red thus invisible to our eye!!! Spent sometime to debug…:sweat_smile:

Thanks @Casper for the excellence example. I’ll try to record the initial step (from the very first step when I get the board), it’s pretty hard to start.

That’s great you got the first part working.

Now for this device handler setup, did you put your external or internal IP as Host? But there’s no need to use external IP (port forwarding i guess), just use the local IP of nodemcu there (should begin with 192.168…), assuming ST hub and nodemcu are on the same wifi network.

Alright I know what the issue is, check my screenshot

EDIT: The function of each button is hard-coded into my Device handler code

Alright let me know what bug are you getting when you have a chance.

Finally I found the issue! Not sure why, but I’ve a few devices not linked to my Hub (In the My Devices listing, they are listed but not linked to my hub), the moment I fixed that, it work!

Thanks for your help again! @Casper

I think the battery life can be improve if implement the sleep function. I can imaging that the whole device can be put into deep sleep mode when no one at home / after mid-night etc. I’m looking at the link below, hopefully it’s not too difficult to implement.

@JZst, to implement on/ off, volume, and channels control via Alexa, I need to create multiple devices?