Marko Mäkelä’s electronics projects: RS-232 Solid State Relay


I set up a VDR system based on the VDR softdevice plugin. The plugin has a suspended flag for stopping the resource intensive MPEG-2 decoding process. I wanted to connect that flag to a solid state relay, so that the monitor will only be powered on when video is being displayed. Later, because of technical limitations of the plugin interface, I wrote a patch to introduce a suspend flag in the VDR proper.

[RS-232 Solid State Relay Box]Hardware

The hardware is very simple, consisting of a solid state relay, a fuse, a switch and some cables.

Bill of Materials

Wiring Diagram

[Wiring the Solid State Relay]The wiring diagram has been drawn with CadSoft EAGLE 4.11.

The solid state relay is very simple to connect. When there is a positive voltage between the control terminals, the load will be connected. If you are driving the solid state relay from the RS-232 port, make sure that it works with a control voltage of 3 to 15 volt.

A solid state relay does not require the connection of any protection diode in parallel, as there is no inductive load between the control terminals. However, the solid state relay might not tolerate negative control voltage, while RS-232 signals normally are either negative or positive. So, you may need to add a series diode to one of the control terminals in order to limit the voltage from the RS-232 port to zero or positive.

The diagram only shows the wiring of one mains wire. Let the other wire pass directly through. If you are using a three-contact cable, let the ground wire pass directly through as well. Isolate all mains wires from the RS-232 cable and the control terminals of the relay!

Do not forget the fuse. My solid state relay can drive up to 10 A of continuous load. In case the relay box is connected to an outlet that is protected by a bigger fuse, the internal slow-blow 10 A fuse is absolutely necessary. If it is missing, the solid state relay is likely to be destroyed in the event of a short circuit.


It is fairly easy to control the RS-232 port from software. Most modern systems implement the POSIX termios interface. Microsoft Windows has fairly similar functions, but they are named in a different way.

Using RS-232 lines as GPIO

I have written a simple example program for driving and monitoring the RS-232 lines. I originally wrote the program in order to provide a repeatable test case for a bug in the Windows driver of the FTDI FT232 USB-to-serial converter. If you physically connect RTS and CTS and change the state of RTS with this program, the driver will report the previous state of the CTS signal. The manufacturer ignored my bug report. Unfortunately, the Linux driver is not bug-free either. Bitbanging does work, albeit very slowly, but the ftdi_sio driver does not seem to implement XON/XOFF flow control properly. Surprisingly, that feature does work in the Windows driver, if you do not mind that WriteFile will not correctly return the number of bytes written when a timeout occurs. Moral of story: avoid USB-to-serial converters, as most of them have buggy drivers.

You can download the example program as It contains the C source code for POSIX termios and Win32 and a Win32 executable that was compiled with MinGW. The program is in the public domain.

Patch for VDR 1.3

The vdr-suspend patch has been moved to my VDR patch page.

Conclusion and Related Work

On my VDR system, the relay box controlled a VGA monitor and the power supply of stereo speakers. The display remains powered off during timed recordings and other non-interactive use of the computer. Only when the computer is started by remote control (see Wake-on-RC5), also the display will be powered on.

Later on, I switched to a video monitor with a built-in speaker. To save space, I installed the solid-state relay inside the monitor. Now, my VDR system consists of exactly two boxes: the monitor and the computer containing the video storage and tuners. I cut two 6 mm holes to the back panel of the monitor: one for a 3.5 mm mono jack carrying the control signal from the RS-232 interface, and another for an override switch. As the power supply of the monitor already contains a fuse, I did not have to install one.

After over half a year of service, the mains side of the Teledyne 615-2H in the original relay box suddenly went to short circuit at the moment when I switched off three fluorescent tubes in the same room. To prevent the same from happening again, I added a varistor between the mains contacts of the relay. Time will tell if this will give adequate protection.