In a smart home, electronic appliances can be controlled through voice or gesture, including a TV set. Unfortunately, this feature is not available in most TVs. To use such a feature, a Fire TV stick is needed, but it gives only limited TV access. So we decided to control TV with Alexa.
So, here is an exciting IoT project to make an Alexa IoT TV controller that will solve the problem. The system works by connecting Alexa to an IoT device over Wi-Fi. The IoT device receives commands from Alexa to trigger the IR LED for controlling the set-top box or TV.
The Alexa IoT TV controller is not just restricted to controlling TVs. You can use it to control any device that uses an IR remote control. Sounds interesting? Gather your tools and let us get started with this terrific IoT project.
To install the ESP8266 board in Arduino IDE, go to Files→Preferences→Paste the http://arduino.esp8266.com/stable/package_esp8266com_index.json URL. Then go to Tools→Board Managers→Search esp8266 and install the board in Arduino IDE.
Also, install the library espalexa in Arduino IDE, which will allow Alexa to control the IoT appliances that have been added to the Alexa app. Next, install the IR remote library that will allow you to decode the hex code for transmission to the TV.
Coding
We need to write two codes: one for ESP8266-01 which will be used as an IoT device for Alexa and the other for Arduino which will trigger the IR LED to control the TV. For controlling the TV using Alexa, create the code using espalexa library. It also allows the addition of lighting devices to Alexa. However, do remember to set the function for passing the control commands to Arduino for controlling the TV instead of the lights.
Esp8266-01 code
For writing the code, first, initialise espalexa library and then add the required device(s) in the code so that Alexa receives the function of individual buttons of the TV remote.
Note. Since espalexa cannot be made to work as a remote device, use the following hack instead. Create a function for light, which will trigger the IR LED of the TV and enable you to control it like an IR remote. For example, for the ‘on’ button, create a function named as Light 1 in the code. Continue adding 13 to 14 separate functions, say, Light 1 up to Light 13 (as per requirement) for performing other operations.
In the setup function, set a serial baud rate of either 9600 or 115200 so that commands can be successfully passed on to Arduino.
Create a loop function for setting the function of devices such as Light 1, Light 2, etc.
Whenever Alexa is given a command, it will trigger functions Light 1, Light 2, etc. associated with a specific connected device, that is, a TV remote. These functions correspond to commands like volume up/down, TV on/off, next channel, favorite channel, etc.
Arduino code. Write the code for Arduino to retrieve commands from espalexa and then trigger the IR LED to perform as a TV remote control.
Please register to view this article or log in below. Tip: Please subscribe to EFY Prime to read the Prime articles.