Voice Controlled HDMI Switch

by ehsiung in Circuits > Remote Control

5676 Views, 23 Favorites, 0 Comments

Voice Controlled HDMI Switch

main.jpg

What do you do when your television has 3 HDMI inputs but you have 4 (or more) devices that you want to connect? Well, there’s a lot of reaching behind the television and swapping cables. This gets old pretty fast.

So the first thing I did was to purchase an HDMI switch (https://goo.gl/6xtzUp). This addressed the issue of swapping cables around, but you still had to reach behind the television set to push the Select button on the switch.

I wanted some way to control the HDMI switch remotely, without the need to physically access the switch. I’ve been playing around with wifi-connected microcontrollers, like the Particle Photon and Digistump Oak, and thought it would be a fun project to make the HDMI switch voice-controlled.

The idea here is to interface the Particle Photon to the HDMI switch, and then control the Photon via Alexa. In addition, one of the devices is a Chromecast and I wanted to power it up only when it was needed and to leave it powered off at all other times. If you do not have a Chromecast it should be easy to figure out which bits of the project to modify or leave out.

Materials needed:

Tools:

  • Soldering iron and accessories
  • Wire stripper and cutter
  • Multimeter

Services:

  • Amazon Alexa developer account
  • IFTTT account (https://ifttt.com)
  • Particle.io account

To power this project I used a 12VDC wall wart that fed a DC-DC converter set to output 5VDC. You can also use a 5VDC wall wart directly but review the information in the Photon datasheet about providing power. https://goo.gl/MdwMp1.

This will not be a tutorial on how to setup Alexa, IFTTT or Particle, and I’m going to gloss over a lot the details about using them since they are well-documented elsewhere (and, honestly, I've forgotten a lot of the details!). If you have not worked with these technologies previously you may want to read some documents and review some tutorials before proceeding.

Open It Up

IMG_20180317_112743435.jpg
IMG_20180317_112208404.jpg

I started by taking apart the HDMI switch to see what’s inside.

I probed the circuit board with a multimeter and determined that:

  • it is powered by 5VDC from the connected inputs,
  • the Select button works by pulling a line to ground, and
  • each LED has about a 2V drop across it when lit.

At most one of the LEDs is active at any one time. So by connecting the LED anodes to Photon analog pins, I can determine which one is lit, and thus, which HDMI input is currently being routed to the output port.

To mimic pressing the Select button I can simply pull one leg of the Select pin to ground. This causes the HDMI switch to route a different input to the output.

Toggling the Select switch and monitoring the LEDs to determine the outcome is just what I need to control the HDMI switch remotely.

Wire Up the HDMI Switch

IMG_20180319_163402318.jpg
IMG_20180321_161737090.jpg

To monitor the LEDs, I soldered a lead to the anode of each LED.

To toggle the HDMI switch, I soldered a lead to the high side of the Select button.

I also soldered a lead to a convenient ground. This happens to be the low side of the Select button but other locations would have worked as well.

Lastly, I drilled a hole through the case, threaded the wires through the hole and put the HDMI switch back together.

Wire Up the Particle Photon

wiring diagram.png
IMG_20180325_105849239.jpg
IMG_20180325_105838020.jpg
IMG_20180327_210002498.jpg
IMG_20180327_205915464_HDR.jpg

I used some perfboard to mount the Photon and then connected the LED leads to A0, A1, and A2 on the Photon, the Select button to D6, and ground to ground. To control the power to the Chromecast dongle, I added a p-type MOSFET as a switch, which feeds power out through a USB type A female connector. The MOSFET gate pin also has a 10K ohm pull-up resistor.

There is also a pushbutton that pulls D1 to ground, but it is not used for anything right now.

To power the Photon, I used a DC-DC converter since the Photon datasheet (https://goo.gl/MdwMp1) has some warnings about keeping the power leads short.

In addition, note that the Photon is nominally a 3.3V part so it might seem dangerous to connect it to a 5V part. But datasheet says that the digital pins (like D6 that I am using) are 5V-tolerant. As noted above, the voltage drop across the LEDs is around 2V so no problem there.

The final picture shows the completed hardware. Obviously I need to put this in a project box or case of some sort, but that'll be a future project.

Program the Photon

build.particle.io.png

If necessary, follow the Particle guide and setup up your Photon (https://docs.particle.io/guide/getting-started/start/photon/). Then, start up the Particle Web IDE (https://build.particle.io), create a new app, paste in the attached hdmiswitch.ino script and flash your Photon.

I'm glossing over a lot of details here but if you are new to the Photon, the Particle web site has some great documentation. https://docs.particle.io/guide/getting-started/int...

I've included a hdmiswitch_tester.py Python test script that you can use to interact with the Photon and exercise the switching functions. First, you will have to edit the test script to add your Photon device ID and Particle access token values. Then, from the command line, run python hdmiswitch_tester.py XXX, where XXX is tivo, dvd or chromecast, to switch between devices. The Tivo and DVD player of course have to be powered up in order to switch to them. Run python hdmiswitch_tester.py --help to see what the command syntax is. This script should work on Windows, Linux and Mac, and you will need to have Python 2.7 installed.

I have a Chromecast attached to the switch port 1, a DVD player on port 2 and a Tivo on port 3. You can modify the scripts to suit your particular set of devices.

There is some delay when switching to the Chromecast since it has to power up, and this takes about 30 seconds.

Set Up Alexa and IFTTT

ifttt_chromecast.jpg
Test of voice controlled HDMI switch

Once things are working with the python test script, you know that the Photon is communicating properly over the Particle cloud service. The next step is to set up a way for Alexa to issue the same commands as the test script. This can be accomplished by creating an IFTTT app that integrates the Alexa and Particle cloud services.

Login to IFTTT and set up 3 apps using these screenshots as a guide. My 3 phrases are "chromecast", "dvd player" and "tivo", but you can customize things to whatever you need. Just remember to make the appropriate changes to the hdmiswitch.ino code.

The video shows the HDMI switch in action. I can now command Alexa to switch the television from Tivo to DVD player to Chromecast. Note that Alexa sometimes does not understand the request so I may have to change the trigger words to something easier for it to understand. I also swapped out the short HDMI cable from the switch to the television with a longer one so the switch doesn't just dangle off the back.

And that's all there is to it. I skipped over some details so please post any questions you may have and I'll do my best to answer them. I hope you found this project interesting and useful!