Voice Controlled Remote Controller Via Amazon Alexa

22K10066

Intro: Voice Controlled Remote Controller Via Amazon Alexa

Remote controllers, like your A/C and TV remotes, communicate via an IR Singal powered by an Infrared LED. In layman's terms, your remote controller simply sends a beam of light (much like a flashlight) to your TV.

Ever notice the little LED bulb sticking out of the front of your remote control? Well that's an IR LED used to send unique infrared signals to your TV, A/C etc.

The device we'll be building is an IR Remote Controller, much like your ordinary TV remote controller. The difference is, we'll be able to control our remote controller via Amazon Alexa. So you'll be able to voice control anything that works with a remote controller, be it your TV, satellite receiver or air conditioner; basically this device will be able to mimick any remote controller lying in your house!

Things Used:

1. Amazon Echo Dot (any Amazon Alexa product should work fine)

2. ESP8266

3. IR Receiver

4. IR LED

5. Jumper Wires

6. Breadboard

STEP 1: Connecting the IR Receiver

The first step is to identify what IR signals each of your remote controllers, and their buttons, send to communicate with your TV or A/C. We'll be able to find that out by using an IR receiver/sensor.

IR codes can be found online for many mainstream brands like LG and Panasonic. If you opt to do that, you can skip to step 4.

Connect the IR receiver to your Arduino as shown in the diagram above.

STEP 2: Arduino IDE & IRremote Library

For this step you will need to install a library called IRremoteESP8266, and for that you will need the Arduino IDE. If you don't already have the Arduino IDE, you can download it from here - https://www.arduino.cc/en/Main/Software.

After you've installed the Arduino IDE, navigate to the following link and follow the installation instructions for the IRRemoteESP8266 library we're going to use - https://github.com/markszabo/IRremoteESP8266

Once you've installed the library, navigate to the IRremoteESP8266 examples folder, (this is found wherever you have your Arduino IDE installed) and open the IRrecvDumpV2 folder;


Arduino > libraries >IRremoteESP8266 > examples > IRrecvDumpV2 > IRrecvDumpV2.ino

Now, open the IRrecvDumpV2 file - we'll be editing and uploading this code in the next step!

STEP 3: Coding the IR Receiver

Within the code, make sure to change the recvPin to the one used to connect your IR Receiver to your ESP8266 (GPIO Pin 2 or D4 if you followed the diagram in the previous step).

Connect the ESP8266 on to your computer.

Make sure the correct board is selected on your Arduino IDE. You can change this by going to Tools > Boards > NodeMCU 1.0 (ESP-12E Module).

Now upload the code onto your ESP866 by clicking on the upload button, this usually rakes several seconds.

Once uploaded, open up the Serial Monitor (Tools > Serial Monitor).

Make sure your baudrate is set to 115200.

STEP 4: Gathering IR Codes

You can now press buttons on your remote controller and the IR Receiver will display the unique IR Signals on your Arduino IDE serial monitor.

Notice that you have get various data values (see image above), the important things to note are the Encoding Type, Code, Number of Bits, uint64_t value and the uint16_t rawData value (which is the Code with a "0x" prefix).

Make a note of all these values, being careful as to which button on your remote corresponds to each code. We'll be using all this data in the next step!

*Make sure to get a few consistent readings as there may be interference.

For my AC, I could only extract the rawData, but for my TV I obtained valid hexcodes as well as rawData. Your data will likely have different encoding types and codes.

STEP 5: Testing IR Signals

Now it's time to see if the IR Codes you collected in the previous step actually work! We'll do this by connecting an IR LED to the ESP8266 and send the same IR Signals we decoded in the previous step. Your TV/AC should respond to these signals just as it would tonyour remote controller.

Let's start by connecting the IR LED to the ESP8266, simply follow the diagram above.

Next, navigate to the IRremoteESP8266 examples folder once again, and open the IRsendDemo folder;
Arduino > libraries >IRremoteESP8266 > examples > IRsendDemo> IRsendDemo.ino.

Open the IRsendDemo file and edit the code, replacing your the IR Codes according to your Encoding Type, Number of Bits (for hexcodes) and Frequency (for rawData).

The next thing to do is upload your code and point at your device to get a response.

If your devices are responding correctly to your IR Signals, and you are happy with your results, move on to the next step where we'll be coding these IR Codes so that Alexa will pick them up as devices.

STEP 6: Coding for Amazon Alexa

If you're reading this, you're almost done!

First thing to do is to download the code from my github --> https://github.com/nugoo1/Alexa-IR-Remote

Use the files Office_AC.ino (uses rawData) and Office_TV.ino (uses hexcodes at 32bits) as examples.

Edit the code replacing your Wifi username and password. Next, replace the IR codes, port numbers (use ports higher that 1024) and device names. Alexa will pick up these names (but you can always edit these names later on the Amazon Alexa app.).

You can add up to 10 devices, it get's a little buggy when adding more. Make sure to add unique callbacks and listeners for each extra device you add.

STEP 7: Add Devices to Amazon Alexa

Now open up your Amazon Alexa app. and you should be able to discover all your new devices (IR Codes).

Simply search for new devices and they should pop up (see image above).

Now you have your very own voice controlled remote control! You can use what you've learnt to voice control almost anything that uses a remote controller through your Amazon Alexa.

STEP 8: Voila!




All done. Enjoy :)

If you would like to print a case for your ESP8266, follow the link --> https://www.thingiverse.com/thing:1781822

46 Comments

getting error :- Library install failed: library not valid
Hey buddy, i am interested in doing this project and implementing it for a customer. Is there any way I can speak with you over the phone? I have a few questions.
can you please help me to solve this error?


invalid conversion from 'void (*)()' to 'CallbackFunction {aka bool (*)()}' [-fpermissive]
you can use light level from 1 to 100 to change tv channel
Could you please provide more details on how you did this?
Hi, a huge thnx for sharing all of this.
I have managed to compile the sketch, but i have truble discovering the device in Alexa app.
Looking at the serial monitor i can see the device connected to my wifi and during the Alexa scanning process i can see the device anwering to a setup.xml call.
But i cannot discover my esp on the app. Any clues?
Make sure your phone and nodemcu is connected to same wifi network
Can we use this entire thing with google mini also ?
If so can u put on the link for me
nice tutorial! i made it through to the end and got alexa to turn on and off my stereo and mute it for me! I ran in to an issue when adding a third callback/switch for a mode for my stereo when i compile it keeps coming up undefined where i put the lightThree even tried using outletOne for the third with no progress.
The code seems incredably simple for what it does. I have a bunch of complicated mqtt protocols going to OpenHAB and the use Phillips Hue Emulation to hook up with Alexa...

Nice project you've made, I might just end up using the idea to control my T.V.

Thanks for sharing! Cheers
Hello, my name is Manolo and I would like to introduce myself.
I have a problem at the end of the tutotiar, when I try to compile the Office_TV I get this error, switch.h: No such file or directory.
You could help me.
P.S. Sorry for my English, I am using a translator.
Thank you.
Thank you very much for your information, tomorrow I will try and if you do not mind, I will follow you asking questions.
Thank you very much for your information.
No problem, good luck
Hello, do I have to install any application on the mobile or Skills in alexa ?.
Thank you.
Nope it should automatically discover the device
Hi, I have problems with the original controls.
With your manual I get to point 4 well, but, every time I give the power button, for example, I get a different code.
The original ignition button has 4 functions:
If you press once, it starts at the first speed.
If you press again, the second speed is set.
If you press again, the third speed is set.
And if you press again, the fan turns off.
There is never a repeated code, they are always different.
I have no idea how to do it.

More Comments