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