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

project_hvac
project_remotes

(Casper) #1

Hi guys,

I’ve been working on a project to make my “dumb” fan “smart”, initially I was going to use a RPi but the board is kind of large and not really portable. Then I discovered this ESP8266 board, it’s tiny, cheap, has Wifi built-in and requires no SD cards.

Now my fan is “smart”, it can be controlled from ST, Alexa, ST smartTile dashboard. It’s powered by 2 AA batteries (completely wireless).

I’m not really good at describing so please see for yourself: demo video here, and some photos here

The hardware includes: ESP8266 board, small breadboard, AA batter holder (3v total), and the IR kit

Software includes:

After all those steps, I could already control the fan from a local web endpoint, then I wanted to integrate it with SmartThings. Since this is merely a web endpoint and all I need to figure out is how to send a GET request from ST to this local endpoint. Although I was aware of MQTT (still don’t know how to use it yet), I decided to grab the HTTP Device handler, big thanks to @JZst, and simplified the code because all I need is to send a GET request without any return value.

Now I can control the fan from ST iOS app, Alexa, and SmartTiles dashboard. I also control a TV using the same method… with this universal IR remote, imagine all the possibilities :sunglasses:

Here’s the demo again: demo video here, and some photos here

Let me know if you like it, sorry for long post. :sweat_smile:

EDIT: I take back the wireless feature, completely forgot about web server running on wifi, so 2 AA batteries won’t last more than 2 days. Now I have to hook it up to a power outlet :cry:

EDIT 2: I saw some people trying to make 1 of these, I’m sorry for the horrible write-up, but please do PM me if you have any issue during setup. There were a lot of issues/bugs in the process for me, but you don’t have to spend your valuable time again. So let me know if you’re stuck somewhere and I’ll be glad to assist. :slight_smile:

Added some pics, including a TV remote (currently I only implement ON/OFF to use with Alexa)





ESP8266 / NodeMCU / Arduino based TV Remote
Discontinuation of MyQ Connect Community SmartApp
On / off control via IR of a split unit Air Conditioner
ESP8266 / NodeMCU / Arduino based TV Remote
Turn off "Fan" without turning off "Roku" in Harmony
Convert Electronic Switch to Mechanical (Bionaire Fan) for use with smart outlet
Alexa + SmartThings + IFTTT + Harmony to turn TV on and off by voice (2015 version)
Raspberry Pi with PHP (or Arduino/ESP8266/NodeMCU) to GPIO to Relay to Gate/Garage Trigger
Suggestions how to turn on a device such as a AC Unit or Floor Fan
Stereo with Z-wave, wifi or zigbee integration
Simon XT/Z-Wave integration?
Any device handler that can pull data from an API and display as a single tile?
(Jdmcgee) #2

I like your ingenuity. I picked up a few different esp8266 boards but haven’t had time to play with any of them yet… I might make a version of this one of my first experiments. Thanks.


(Frank) #3

Casper, with your post on another thread this week picked up two of these little things from Amazon. My goal was to replace a Raspberry/Arduino sprinkler project that I am working on. What id does not is Smarthings send post command to the Raspberry webserver which triggers a python script that speaks via RF24 to the arduino. The arduino is setup to control a 8 channel relay for my garden sprinkler. It took me a few weeks but it works. Unfortunately I am not getting the range I want and I have two use two device. When I received these device I was quickly able to get a webserver running on wifi, and convert my logic to the esp8266 board , right now I am control led but I will replace this with the arduino this weekend. Now I have freed up my pi and I have a arduino to play with.

Thanks for the idea.


(Casper) #4

That’s great, I never had any Arduino before because it’s expensive when we add Wifi functionality, fortunately there’s ESP8266.


(zraken) #5

Appreciate the detailed post. This gives me a jump start on a esp8266 project that I’ve been meaning to do for a while. I’m hoping to do a cheapo substitute for a Harmony Hub (which is effectively what you’ve done).


(Casper) #6

Yea with this tiny board, you can make all the IR remote controlled appliances in your house smart, way cheaper than Harmony Hub and completely no string attached.


(Benji) #7

AWESOME work! Bet you’ll be on Hackaday in a few days no doubt!


(Casper) #8

Thanks @Benji, I actually never been on Hackaday before, maybe it’s time to check it out :smiley:


(JZst) #9

@Casper thanks for putting this together. Eagerly awaiting my ESP arrival and mostly thinking of putting it behind wall switches with a relay. Zwave switches or relays are expensive to do throughout and this is so much nerdier and cooler :slight_smile:

Appreciate the answer to my question… looks like you simply add the SSID and wifi password to the Arduino sketch and done deal for wifi configuration — can’t get any easier than that.


(Casper) #10

Yes it’s really simple as that, thanks to those guys who made the framework, as long as you can spin up a server with buttons that can trigger desired GPIO pins… integration with ST is piece of cake (thanks to HTTP device handler of course).

These esp8266 boards are ideal for relays, cuz we don’t want to use a full computer (RPi) to just trigger some GPIO pins.


(Benji) #11

Low and behold, you’re famous :smile:


(Casper) #12

Haha this is awesome, I’m on the news :laughing:

Thanks @Benji for tipping Hackaday writer :smile:


(Benji) #13

I actually think they would have probably picked up on it anyway because Hackaday has a massive… well, they love the hell out of the ESP8266 shall we say :smile:

Regardless, excellent work!


#14

I have a rev1 uno board, would I be able to accomplish the programming of the esp8266 using that? I need to get a small arduino kit as I don’t have parts (breadboard, wires, etc) to put this together.


Connect NodeMCU to SmartThings
(Casper) #15

I’m not sure but I guess if it has wifi then you can try with this code.

This Arduino framework is built for ESP8266 so I don’t know about the actual Arduino, but I bet you can find a library to build an IR remote with simple web interface via Wifi. If you can get to this step, integrating it into SmartThings can be easily done using HTTP device.


(JZst) #16

@eibyer yes you should be able to buy JUST the esp8266 alone to connect to your UNO. This project uses the NodeMCU which INCLUDES both the esp8266 wifi board, a voltage regulator chip and programmable flash chip (which your UNO is). Having said that, with the price of this NodeMCU, why would you not get a stand-alone integrated unit that was linked in the OP to Amazon. This way you get to play with the UNO and not have a bunch of jumpers/connectors, etc. NodeMCU is tiny like 1x2 inches. Much better than UNO plus esp8266 and an IR unit. That will be a mess.

@Casper maybe include that in the title because esp8266 is just a piece of that NodeMCU board. I finally got my stuff in and got pretty far. I easily read in the raw IR data from my various buttons that I wanted to automate. I also made sure simple and complex sketches work like a charm. However, I load your code in, as is (just wifi info changed), and upon reset of the NodeMCU, it will never come back up with the IR LED (sender) connected to GPIO0 (D3 pin). I studied your pics very closely. I’m pretty sure I’m doing this right especially because I’m able to use the IR receiver w/o issues on the same pins. My guess is my sender LED is busted. Every time I use your code, it lights up amber upon reset and the serial monitor shows that it does not load. The I unplug the IR LED and reset, it easily connects to my wifi and serves up the page w/o issues. I’m attaching images showing my wiring along with the serial monitor output. That success connection to wifi is only possible if I unplug the IR LED. Thanks again for your hard work, I easily started up with Blink, the Web Server LED to validate the abilities of the board then I just went ahead with IR project.

BTW, when I unplug the IR LED, reboot, the website works, then connect the IR LED and it is NOT amber and the web page still works. I try sending my raw IR data (just replaced your single TV line with mine) and it does not work. Then I reset the NodeMCU, IR LED board is lit amber and the website does not work.

Thanks again!!!


(Casper) #17

Hey @JZst, great to hear you already got it started.

I ran into this issue many times before, either the GPIO pin of the IR Led is incorrect (I’m pretty sure I’m using D2 pin for IR emitter), or when you open the output log, the Baud port is not 9600 like it’s defined from the sketch.

I’m away from computer for a few days so can’t give you exact solution, will update with exact code when i get back on Tuesday.

Anyway let me know if this helps.


(JZst) #18

Wow dude, you da man! You remembered D2 and that was the key. I see this line of code:
IRsend irsend(4);

Which means GPIO4 per the pinout and that is indeed D2. That was my issue. Now when I send IR, I do see the amber light for a fraction of a second and my TV definitely turns on & off as expected. AWESOME!!!

Only drawback is these IR LED’s are not made for distance which kinda sucks :slight_smile: I may be able to find a more distance-friendly one. Thanks again!!!


(Casper) #19

Congrats dude :wink: The blue led on the nodemcu shoud never light up if everything is right.

And yeah the distance of this IR sucks, that’s why you saw me putting the module on top of the fan haha. Please do let me know what you can do about it.


(JZst) #20

Okay bro, lots of research and everything pretty much works. The only drawbacks so far is the ability to do it all via Alexa. I have to create a different device for each thing like volume & channel changing. On command would do + while Off does - with volume & channels.

I have an HDMI switcher connected to that TV and I have built in a simple slider in ST. That works well but no matter what I do, I can’t get Alexa to respect “set to X” voice command like my light-bulbs are able to accept from Alexa->ST integration. I am posting that code in a bit and will report back with the link. Hopefully somebody smarter than me can tell me why a slider can’t be used like I’m using it.

So the cheap Chinese HDMI switcher box was not working until I started using sendNEC method rather than sendRaw. This seems to work great but that’s because the IRremote Arduino library knows about the older NEC standard. It worked like a charm and looks like this:
irsend.sendNEC(0x1FE40BF, 38);

LG TV works easy and so does Samsung. What failed me for a while was DirecTV. Using the links just below, I figured out that when I dumped the IR data, it was only dumping 19 parts. However, the link below clearly shows 20 need to be sent including a long 30,000us signal as the “ending” — after I found that and it worked, I was sailing. See the lists below for full reference.

Library of many IR code sequences:
http://irdb.tk/find
http://www.hifi-remote.com/johnsfine/DecodeIR.html

IRLib — IRremote’s more inclusive fork/re-work which uses object-oriented C. Has ability to decode/send DirecTV IR controller functions while older libraries like IRremote and IRremoteESP8266 would require modification. Once I found my DirecTV solution, this was a bit of a moot point to try.

FYI — have a look at this guy’s other post and it will make you realize how lucky we all are and why he (Chris Young) coded this library which is to overcome some of his physical constraints. This guy is a true inspiration and makes me feel like a simpleton :slight_smile: If I run into a brick wall I may post on his blog and ask how a lament like me can see an example of exactly how he anticipated that folks will incorporate “add-ons” like the DirecTV piece of code that he provides and comments at the top but not quite clear enough for me to move forward.
http://tech.cyborg5.com/2013/02/16/announcing-a-new-infrared-remote-control-library-for-arduino

For distance, I bought TSAL6100 IR LED’s from eBay and plan to simply replace the IR LED that I have on the little board which is the same thing that is linked to in the OP: http://www.ebay.com/itm/262136736326

If that doesn’t work, then I simply have to do what everybody is recommending which is a transistor (plus diodes) to amplify IR LED. I’ll let you know if simply soldering on a stronger IR LED fixes the issue and if not, something like this is required:


http://tech.cyborg5.com/2013/03/14/irlib-tutorial-part-1-hardware-set-up