Voice Controlled Remote Controller Via Amazon Alexa

14,117

83

38

Introduction: Voice Controlled Remote Controller Via Amazon Alexa

About: Fullstack Developer from Colombo, Sri Lanka

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

First Time Author

Participated in the
First Time Author

Be the First to Share

    Recommendations

    • Puzzles Speed Challenge

      Puzzles Speed Challenge
    • "Can't Touch This" Family Contest

      "Can't Touch This" Family Contest
    • CNC Contest 2020

      CNC Contest 2020

    38 Discussions

    0
    mamidibathula.akash
    mamidibathula.akash

    2 months ago

    Can we use this entire thing with google mini also ?
    If so can u put on the link for me

    0
    skdemont
    skdemont

    Question 2 months ago

    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.

    0
    sagramor_80
    sagramor_80

    Question 5 months ago

    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?

    0
    ArduinoMaker
    ArduinoMaker

    9 months ago on Step 6

    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

    0
    The Expert Noob
    The Expert Noob

    11 months ago

    Anyone having issues, you need to install the ENTIRE library from here manually, not just switch.h.
    https://github.com/kakopappa/arduino-esp8266-alexa-multiple-wemo-switch

    Also, the wemos library now works off bool not void. The wemos lib "switch.h" should be as well as other libs included below it. Here is an example of my code with modifications. Also fixed the issue with Alexa reporting "device malfunctioning" when turning off a device.

    https://pastebin.com/kEU5V3Kz

    0
    crack12
    crack12

    1 year ago

    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.

    0
    crack12
    crack12

    Reply 1 year ago

    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.

    0
    NuwanG1
    NuwanG1

    Reply 1 year ago

    No problem, good luck

    0
    crack12
    crack12

    Reply 1 year ago

    Hello, do I have to install any application on the mobile or Skills in alexa ?.
    Thank you.

    0
    NuwanG1
    NuwanG1

    Reply 1 year ago

    Nope it should automatically discover the device

    0
    crack12
    crack12

    Reply 1 year ago

    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.

    0
    NuwanG1
    NuwanG1

    Reply 1 year ago

    Do you mean to say that one button sends out different codes? There should normally be one unique signal/code for each button...
    But I have had the ir receiver give me different values for the same ac button (raw data is not as consistent as hex codes in my experience), but I kept trying and made a note of all the different codes I got and experimented. I stuck with the code that the AC best responded and discarded the rest...

    Hold you IR receiver near the fan... Make sure the fan works with the normal remote and get the codes by keeping IR receiver near the fan... Good luck... It'll all be worth it when u get it to work! Trust me ur almost there, I got stuck just like u :)

    0
    crack12
    crack12

    Reply 1 year ago

    Thank you very much for your advice and encouragement, I managed to get the codes through a universal remote and an old TV.
    Now what I don't understand is how the codes get into the IRSENDDemo.ino
    If you don't mind, I send you a txt file with the codes, and you tell me how they get.
    So I can put other codes of other devices.
    I really thank you for your invaluable help.

    0
    NuwanG1
    NuwanG1

    Reply 1 year ago

    Hey could u pls make a repository on github? It's easier for me to look at the code...

    0
    crack12
    crack12

    Reply 1 year ago

    Hello, I have already been able to put the codes and the TV recognizes me well.
    Now there is the problem that I don't know how the switch.h library gets to do the last step of your tutorial.
    I downloaded this, what you told me, "arduino-esp8266-alexa-multiple-wemo-switch" I put it where I have all the libraries and it tells me that it is an invalid library.
    Thank you.

    0
    NuwanG1
    NuwanG1

    Reply 1 year ago

    Mmm not sure, just keep trying ull figure it out

    0
    NuwanG1
    NuwanG1

    Reply 1 year ago

    Got these answers from the arduino forum... https://forum.arduino.cc/index.php?topic=515864.0

    There are three common causes of the invalid library warning:
    • You saved a sketch to the libraries folder. Sketches are only allowed in that folder as examples inside the folder of a valid library. Fix: move the sketch anywhere else other than the libraries folder.
    • Incorrect installation of a valid library. The library folder must be directly under the libraries folder, not in a subfolder. This means the library must have either a .h file or a library.properties file in its root folder. Fix: move the library folder to directly under the libraries folder.
    • Something that's neither library nor sketch in the libraries folder. Fix: move it somewhere else, anywhere other than the libraries folder.
    0
    crack12
    crack12

    Reply 11 months ago

    I've got TV to recognize Alexa.
    In principle I am doing well but, for example on TV, I say "Alexa, turn on LG", Alexa turns on the LG and says "OK", but if I say "Alexa, Turn off LG", Alexa turns off the TV well but he replies, "LG doesn't answer."
    The same goes for the Canal.
    Thank you.

    0
    crack12
    crack12

    Reply 1 year ago

    Hi, how is a github repository made? Forgive my ignorance.