Arduino-controlled HDMI Switch

Introduction: Arduino-controlled HDMI Switch

This instructable will show you how to control multiple HDMI feeds to your TV using a microcontroller such as an Arduino to enable and disable transmission with a single control line.

My ultimate goal is to have a robust but flexible means to limit the amount of time my kids can spend in front of the TV, without getting into arguments at turn-off time. I began working on this after discovering that my kids responded really well to a 'granny-timer' which I installed on their PC accounts. This limits the access times and duration of their activities. When the time runs out, their session ends abruptly. This sounds a bit harsh but the odd thing is that they accept it without a fuss, whereas there would be much wailing and gnashing of teeth if their parents dared to manually flicked the 'off' switch. It was so successful that I thought I would try to get something similar for the TV, but certainly in the UK nothing exists to do this. In the US it's possible to buy things intended for this very job, but as far as I know these only suit US plugs and voltages or they control only composite video etc.

I had it in mind to build an Arduino-based controller with a real-time clock module to reproduce some of the 'granny-timer' functionality. The hard bit was how to switch the TV on and off robustly but safely. So I set about considering the options:

1) control the mains power to the TV - very effective but I worry about adversely affecting the TV in the long term and it involves using mains relays etc.

2) control using IR remote protocols - nice idea but power is almost always a toggle I think, and there's no way for a remote device to know the state of the TV, so in practice I don't think this would work.

3) control by switching the HDMI feeds from the various input devices (we don't use direct RF input to the TV anymore) - this could work but HDMI is a fast signal which needs to be routed and switched carefully - you can't just use a few transistors on a protoboard!

I considered options 1 & 2 to be non-starters. Option 3 seemed like the best way to go, except for the problem of how to carry out the switching. Enter the automatic HDMI combiner and switch which can be bought for less than £5 from numerous traders (via Ebay, for example).

I rapidly determined how to modify this very simply so that a 0-5 V TTL signal would control whether it transmitted or blocked HDMI signals. The modification doesn't impair the manual or automatic channel selection within the device.

The modification is very simple provided you are comfortable with Arduino interfacing and basic soldering. It requires the following:

Cheap 3-to-1 automatic HDMI switcher of the type shown above (can easily be obtained via Ebay, for example). It may be possible to use others provided that they function in the same way. UPDATE - see my other instructable for an alternative HDMI switcher which works in the same way and which I found to perform better with some of my AV sources.

Basic electronics tools

Soldering iron

1K resistor

2N2907 PNP transistor

Hot-melt glue gun

Hook-up wire (e.g. 7/0.2)

I will describe only the HDMI switcher modification in the following pages. It's really simple. I have assumed that people undertaking this modification have 'normal skill in the art' and therefore haven't included circuit diagrams or photos of every single stage in the process. The Arduino controller part I leave to the reader for now as it's likely to be tailored to their individual needs. My plan is to give my kids RFID passes and let them 'log in' to access their TV minutes, which are shown ticking down on a seven segment display. UPDATE - this work has now been published in another of my Instructables.

Disclaimer: this modification worked for me and didn't seem to harm any of the attached AV hardware, but I can't guarantee its suitability for the application so obviously if you carry it out then it is at your own risk.

Step 1: Remove the Power Supply Diodes From the Switcher PCB

Identify the three surface mount diodes D1 to D3, whose locations are marked in red on the figure. These diodes route a +5 VDC supply from incoming HDMI leads onto the board power supply section; the board derives its power from these leads.

Remove the diodes (one is shown marked in green) using a soldering iron to pry them from the board. This effectively disables the board as the switcher IC can't obtain external power. Note that the photo for this step was taken AFTER the diodes had been removed.

The modified circuit board can now be enabled externally by providing an external +5 VDC supply to the power supply section on the board. The +5 VDC should go to the cathode pad of D3 and the supply ground should go to the ground pad near the output HDMI lead (marked GND on the board if you look hard enough). These are marked in blue on the figure.

This is the essence of this hack - control the power to the board and you control whether HDMI is transmitted or not. The manual / automatic switching of individual inputs is retained following this modification.

Step 2: Install a Transistor Switch on the Switcher PCB

The Arduino can't source enough current from a single pin to drive the HDMI switcher board. Its 5 VDC supply rail can source approximately 400 mA however. So the next step is to install a high-side PNP transistor switch to allow the Arduino to control the board from its own power supply via a digital output.

I used a 2N2907 PNP transistor. This was mounted dead-bug style on the switcher circuit board using hot-melt glue. In the figure the rounded side of the transistor faces the outer edge of the board. It's important to keep all the additional components / wires low down on the board so that the enclosure cover will fit back on afterwards.

A black lead was used to connect the Arduino ground to the ground pad on the switcher board.

A red lead was used to connect the PNP's emitter to the Arduino's 5 VDC pin.

An orange lead was used to connect a digital output on the Arduino to the base of the PNP, via a 1 kOhm resistor. I used pin 13 as it's connected to the LED and blink makes a good test sketch. This orange lead is the control line for the high-side switch.

The PNP's collector was connected to the D3 cathode pad on the switcher board.

Hot-melt glue was used liberally to ensure that all the leads and components were secure and that no shorts could occur between the resistor, transistor and the switcher board.

I filed some small grooves in the side of the enclosure to allow the wires to pass through. Provided that the dead-bug installation has been done carefully, the enclosure cover should fit back on without any problems.

Step 3: Conclusion

Okay - that's pretty much it. As it's a PNP high-side switch, HDMI transmission is asserted by setting the control line LOW (0 V). Setting the control line HIGH (+5 V) disables the switcher and thus prevents display of any HDMI signals. Don't worry though - if your resourceful urchins unplug the power supply to the Arduino, they'll lose the all-important 400 mA 5 V rail which will completely inhibit HDMI transmission.

Obviously to use this switcher as a means to control access to a TV, you need to enclose it in a hard-to-open box which encloses the controller, switcher and the plugs of all the HDMI input leads, with holes for the input leads small enough to prevent them from being pulled out and plugged directly into the TV. I intend to mount everything (switcher, controller, display etc.) into a single attractive enclosure that can go next to the TV.

It goes without saying that this will be effective only if your TV is being used as an HDMI monitor. If you leave an RF lead plugged into the TV then that will still be available. In the UK it seems to be increasingly common to use a PVR to take the RF input and provide the TV signal over HDMI, so all you need to do is remove the RF input cable from the TV and hide it or alternatively remove all the channel tuning, to prevent your kids bypassing your controls.

I hope someone finds this information useful. Good luck with building the controller - when I've finished mine I shall update this post.

Hi. When you say 'switching' do you mean on & off or flicking between input channels using the 'select' button? The latter is relatively quick I think, but the former is rather slow. I suppose this is because the hack actually powers up the switcher from cold. It takes the TV on the output a while (a second or two) to realise that an HDMI signal has arrived.

I can't imagine either would be regarded as 'seamless'. I expect you probably have to spend much more money on a switch to get that. The switcher described is very cheap so perhaps you should just see if it meets your needs.

I reckon you could do this, with a little bit of detective work. These switches often have a little button on them which cycles through the input channels. I would guess that it pulls a line on the main switcher IC low (or high) on each press, and that tells the IC to change channels. I would speculate that it would be an easy matter to get your Arduino to supply the control signal in place of the button, but you'll need to do a bit of investigation yourself on an active switcher (and at your own risk, of course). I intended to do this on my TV timer via the Arduino, but it's not a pressing problem at the moment so has gone to the bottom of the in-tray. Please let me know if you had any success and if so, how you did it. Good luck...

Thanks for your interest. In principle I suppose you could buy several switchers and cascade them, but in practice I think you would have serious problems with signal degradation and auto-selection if passing through more than one switch.

Rather than accepting what I say, you could always try it with two cascaded switches, which won't break the bank. If the signal is okay, it suggests that you could build a 9:1 from four 3:1 switches and a 12:1 from four 4:1 switches. If it works, please post, as it's not the first time I've been asked this.

Hi, i want to make a similar project in which i want to switch the HDMI input based on PIR Sensor output.

Like I have an outdoor CCTV Camera which is first HDMI (actually converted from AV to HDMI) and Cable DTH which is second HDMI. So when as long as the PIR sensor senses human-motion, the first HDMI should be switched other wise the second. Earlier when I had an old TV & DTH, i used a DPTD relay to switch the 2 AV input cables from CCTV and DTH which was very easy. But now its HDMI, so cant use a relay. Any idea, how do i interface the PIR sensor output to the button on HDMI switcher. I mean I could use a relay for that micro-switch but is there a particular sequence in which the button should be pressed in your switcher?

On both the switchers I have tried, the button just jumps through the active inputs (i.e. those which are connected to powered-up AV sources) in sequence. So in your case, each press of the button would toggle between the CCTV & DTH.

I suggest you look at the board when it's powered up and see if one side of the switch is either permanently grounded or at 5 V. If the other side is floating until the switch is pushed, then you can probably connect this floating side to an arduino pin to simulate the pushing of the switch (by either setting LOW or HIGH temporarily). This is something I plan to do on my TV timer instructable at some stage (yet to be published but not far off), but I haven't needed it yet as I can still access the switch.

The other problem you will have is to determine which channel is active. You might be able to connect an arduino pin to one of the switch channel indicator LEDs, then have a few lines of code which keep 'pressing' the switcher channel-change button until the LED lights (or goes out). In a two-channel system, this would be a means of knowing which channel is active.

Hey! I'm making a version of this with a vibration switch to turn the HDMI on and off. Could I exchange the PNP-transitor for a NPN? I could perhaps change so that when a aruinopin goes HIGH the transistor is activated?

Hi and thanks for your interest. The hack to the COTS switcher works because the PNP transistor, when conducting, is supplying the 5V DC that was removed by taking out the diodes (a high-side switch). An NPN transistor will only work when you have a permanent 5V supply and are switching the earth on and off to allow current flow in the circuit (a low-side switch). In this switcher everything is referenced to earth (including the screens on the HDMI cables) so I don't think low-side switching would be practical. You may be able to do it in principle but I think it's much easier to remove three diodes than to break all the earth connections in the switcher.

Very useful, thanks a lot. Can you explain to me if it's possible to block/allow certain HDMI input (say IN-2) with this scenario? i.e to install the extra components to control D2? or it's only a power mean that will only power the full switch?

Hi and thanks for your interest. The three diodes removed in this instructible have common cathodes, which feed the power supply to the entire switcher board. Therefore any input lead connected to an active HDMI source would power up the switcher for all channels.

I don't know the answer to your question but I am happy to speculate.If you wanted to control a single channel, it might be possible to do something with the HDMI pin 19 - hot plug detect - on the channel of interest. Unfortunately I know next to nothing about HDMI so you'd need to research this at your own risk. Ultimately it might be safer just to try cascading units (with the externally controlled one just handling IN-2), provided noise build-up or power line voltage drops don't occur. Again, try at your own risk.

If I were undertaking your project, I would see whether pin 19 of HDMI would do what I wanted. If it did (and I stress that I currently have no idea), then I'd use the COTS switcher described (which is designed for the job and is known to work) and look to see if I could interrupt the signal from pin 19 by cutting the relevant trace, then remaking it via a semiconductor switch. I wouldn't dream of attempting to build an HDMI switch from scratch as they are readily available, they cost very little, and they work!

Great project. Did you ever get the arduino and code done and be up for sharing it - I would love to make a timer and token system (eg 30mins per token) for tv and computer with rfid or home network access via smartphone, but that would be a bit beyond me without a starter.

Hi and thanks for your interest - yep it's all coded up and working pretty nicely as a prototype which is fit for my purpose. I've done the first page of the draft instructable, but it will take me a while to complete it though.

Great, I was also wondering about using a raspberry Pi rather than arduino (with it's network support), and it would be possible to have it display messages direct to the TV (some people have used it to switch between inputs), but will wait to see yours, as it's closer to what I want (and easier for me)

So out of curiosity, do you think you could cascade these mux hdmi drivers to get more outputs pending there is enough power? For example, 4x of the 3-1 splitters can get you 9 outputs so it would at most have 2 hdmi chips on at a time then so it would be 800mA. Thoughts concerns? Signal distoration?

Recall that these are not splitters; rather they are switches, designed to select one of three inputs and transmit its signal to the output. So I don't think that you could create a 9-output device by cascading. But there is a good chance that I may have misunderstood your application, as I think such devices can be bought quite easily.

Anyway, assuming that you actually meant '9 inputs', possibly you could try cascading, but managing the auto-select functionality across the four devices would be a real headache, I think. Signal distortion may become a problem as additional stages are added - you'd have to try it. I've also found that every now and again the switcher just won't work properly (or rather the TV can't quite lock to the signal), usually if I have more than one active input. These problems may get worse in a cascaded system.

I have found since the original publication that a single switcher uses a maximum of just under 200mA when transmitting a signal.