Controlling an older TV with Alexa


I have an old TV which was acquired used, without a remote. The power button has become a little finicky. Rather than going out and buying a new TV, or a universal remote, I thought it would be fun to build one. I had a Sparkfun ESP8266 dev board that wasn’t currently being used, and an Amazon Echo Dot in the same room as my TV, so I decided to make an Amazon Alexa-controlled remote rather than build a physical one with buttons.

As I had mentioned in my last post, I’ve built Alexa skills before, and to do this, you need to build a web service that Amazon’s servers can reach - something on the public Internet that can handle HTTPS. I wanted this service that was handling Alexa calls to control this ESP8266 in my home. I don’t like opening up ports on my home firewall, so I had to figure out a way to control the ESP8266 on my home network like every IoT device you can buy off the shelf. I hadn’t done this before, but I knew it was possible.

There seem to be a number of services to make this easy - I came across and PubNub. Blink, in particular, seems like a good choice, as there’s sample code for the ESP8266 micro-controller I had decided to use. But in the end, I decided to use web sockets.

Building the solution

Alexa IR Remote System Diagram

Most of the Alexa Skills tutorials are built on Amazon’s Lambda serverless compute service. But using websockets with Lambda seems to require using Amazon’s API Gateway, and I decided that was too much to take on for this particular project.

I setup the new skill on the Alexa portal, which I configured to call a VM I built out on Azure (I had free credits available there!). On this VM, I hosted a program I built with Node using Alexa’s ask-sdk-core library, and the websockets/ws library to build the web socket server handling the connection from the ESP8266.

On the ESP8266, I used the ArduinoWebSockets library to build the web socket client. Getting the ESP8266 to send IR commands to the TV was super simple. I connected an infrared LED to pin 4 of the ESP8266. Some article I read suggested using a transistor to increase current supplied to the LED, so I did. I used the IRremoteESP8266 for IR, and found the IR codes for my TV on

ESP8266 IR Remote Circuit

Alexa IR Remote on Breadboard

There is no authentication mechanism built in to web sockets. I decided that as I’m not scaling the service, and I’m just playing around, not to worry about it - if you use the code below, beware! The side effect is, every web socket client that is connected to the service will receive every command sent through the skill.

Solution in action

Here are some videos of the solution in action:

Play Turn on TV video

Play Turn up volume video

If you’re interested in trying something similar, you can check out the code here: