Introduction: Super Easy PC Control of 110 Vac Using a Crydom Solid-State Relay

Picture of Super Easy PC Control of 110 Vac Using a Crydom Solid-State Relay

I'm getting ready to try my hand at doing some hot plate soldering. Therefore, I needed a way to control 110Vac from my PC.

This instructable shows how to easily control 110Vac from a serial output port on a PC. The serial port I used was a USB type. Any standard serial port should work.

The idea is to connect the DTR (data terminal ready) pin from the PC serial port to a Crydom solid-state relay. The Crydom relay accepts a control signal of 3 to 32 volts to turn on the solid-state relay. The Crydom relay can also handle up to -32 volts on the control input to the relay. See attached datasheet.

Under normally conditions the DTR signal switches between +10 volts and -10 volts. This works out perfectly for the Crydom relay. The Crydom relay turns on at anything above 3 volts. Any voltage below 1 volt is guaranteed to turn off the relay. So, using the +10 to -10 volts of the DTR signal is perfect. The Crydom relay has a maximum load of 2mA on the DTR signal.

Switching the DTR under program control is also really easy. I've attached a little Python script that toggles the DTR pin every couple of seconds. The Python script is only 16 lines long!

To make the Python code work you will need to add an extra little package to Python called PySerial. I've also attached the windows installer for PySerial to this instructable. With a quick Google search, you can find PySerial on Source Forge easily too.

Step 1: Wiring Crydom

Picture of Wiring Crydom

Caution! Make sure you tripe check everything when working with 110Vac.

The wiring circuit couldn't get much easier than this! The Crydom block is simply inline with the hot side of the 110Vac line. The neutral side passes right through. Pass the ground through too. But, also connect the ground to the heatsink/Crydom block to ground.

I know, I know, the wiring I used on the AC side is to small. I've got a really big Crydom relay (40 Amps!) so I should have some big mother wires. My house has 15 amp breakers so #12 wiring would be OK. I just grabbed an old PC cord and forgot how small the wires are. I think my wiring on the AC side is #18. So far I've just been playing with a 100 watt lamp, so no problem. I'll rewire before plugging in a big hot plate.

Step 2: Python Test Code

Below is the magic Python code. Again, can't get much easier than this. I've also attached the code in a file called "".

import sys, serial
from time import sleep

BAUD = 9600

ser = serial.Serial( COM_PORT-1, BAUD, timeout=0.5, rtscts=0 )

# Toggle the DTR pin on for 15 seconds, then off for 5 seconds.
while ( 1 ) :
print "On"
ser.setDTR( 1 )
sleep( 15 )
print "Off"
ser.setDTR( 0 )
sleep( 5 )

Step 3: Be Careful

Picture of Be Careful

Before I use this Solid-State relay I'm going to mount some Plexiglas over the AC side of the relay. The 110Vac can really bite so be careful!

Hope this helps - Thanks,


infitom (author)2014-10-18

You can control TWO things with two CryDoms: one using DTR (Data Terminal ready), the other using the CTS (clear to send) lines. Just a thought. I'm building a circuit in this configuration, that will first turn on the front light of a haunted house mirror, count 30 seconds, then turn it off, turn on the back light, and take a picture with a webcam:
I'll sense the switch with one of the other serial lines.

frankenp (author)2010-01-04

Thanks!  I just built a similar device to switch off my old analog stereo gear (no remotes) when I put my computer to sleep.  Just tapped into the 5V line on a spare PC power connector.  The hand drawn diagram was very helpful.

jimk3038 (author)frankenp2010-01-04

That is a cool idea.

I wonder if I could use my laptop's USB port? I'm assuming it switches off too when entering into sleep mode. I could use that to switch off my space heater I use under the desk.

Nice idea,

frankenp (author)jimk30382010-01-04

My PC keeps the USB ports turned on during sleep.... so I had to use a power plug.  Some PC's keep their USB powered while others do not.  I like having USB powered during sleep because I can use my wireless usb keyboard to wake the PC.

Callum Snowden (author)frankenp2011-08-01

On my PC, the front USB ports turn off but the back ones only provide power...

frankenp (author)frankenp2010-01-04

Pics of my build mentioned above.  I used two small 3A relays one for each plug..  3 amps per plug is more than enough for my use and the relays fit nicely inside a two gang box.

jimk3038 (author)frankenp2010-01-05

Really nice. I like how everything gets packaged into a plastic box. Being a computer guy 110Vac always makes me nervous. Having everything sealed up is nice.

One thing to watch out for - the 3Amp rating is only good for Crydom modules that have a heat sink / good ventilation. I learned the hard way that the large module must be bolted to a heat sink. I'm not sure about the small modules you are using. But, packing them inside a small box might be a problem. Based on your mounting, I would derate them down to 1 amp.

Looks good,

cowen (author)2011-01-24

I know this is an old Able but what would a circuit look like if you would use a parallel port instead of serial?

LPTs use multiple data lines (8) instead of the serials one line.

By comparison you can use lpt1, 2, and 3 with just 3 cards, where you need a serial port for each control port. USB to serial dongles would allow for more then 4 easily added ports.

Do you think you could email a simple .py file for that interface?


jimk3038 (author)cowen2011-01-24

This was really intended as a quick and easy way to control a single 110Vac device. I used it to control the temperature on an electric skillet while reflowing solder paste.

If you want to control a bunch of outputs at the same time I would be inclined to use a Pic, MBed, Arduino embedded micro instead. With one USB connection you could control an unlimited number of output channels.

Note, there are already these kind of devices on the market. Folks use them to control outdoor Christmas lights under computer control.

Sorry I couldn't be more helpful. I've just never fooled much with the parallel port.

Good Luck,

cgrooms (author)2010-08-26

I have another question for you! Is there any way you can have multiple replays on one serial and if so What pins would I use?. My goal is to control multiple lights. or is that not possible and you have to use two serials pins 4 and 5

jimk3038 (author)cgrooms2010-08-27

Nope, one relay per comm port. However, I can think of two options. You could use a small micro like a Microchip to control a bunch of relays on the comm port. That would make for a low cost solution. Or, you might want to look at an off the shelf solution. Do a Google on "vixen". Folks use that software to control Christmas lights. There are a bunch of relay boards that work with vixen. So, by searching on vixen you will find the relay boards. Good luck, Jim

cgrooms (author)2010-08-22

Thanks so much for your help! I got it to work last night! I just needed for some reason to install python-serial and to specify what serial port I had to modify the code a little

cgrooms (author)2010-08-21

Thanks, I fix that problem now I have this error File "", line 7, in ser = serial.Serial( COM_PORT-1, BAUD, timeout=0.5, rtscts=0 ) File "/usr/lib/python2.6/dist-packages/serial/", line 166, in __init__ File "/usr/lib/python2.6/dist-packages/serial/", line 175, in open raise SerialException("could not open port %s: %s" % (self._port, msg)) serial.serialutil.SerialException: could not open port 6: [Errno 2] No such file or directory: '/dev/ttyS6'

jimk3038 (author)cgrooms2010-08-22

Looks like your trying to open a serial port that does not exist. The easiest thing to do is to use another terminal program to verify which ports are available on your machine. Make sure the terminal app can successfully open the port - if the terminal app can't open the port then Python will also fail by throwing the exception you see in your error message. Edit the known good port name into the Python code and you should be good to go. Good luck, Jim

cgrooms (author)2010-08-13

having the same problem getting errors File "", line 8 print "On" ^ IndentationError: expected an indented block

jimk3038 (author)cgrooms2010-08-13
Sorry to hear your having problems. The Indentation Error is a common error.

Python is kinda weird, in that, it's really picky about indenting in the source code. It drives Python crazy if you happen to indent with tabs and spaces within the same file. Either use spaces, or tabs, but never both in the save file. Some of the better editors have the ability to show tabs with special visible characters. Using this special mode you can verify you have not mixed spaces and tabs. To execute a block of code within some loop like a "while" loop, Python looks for an extra level of indention. The syntax would look like the following.

while 1:

print "Hello World"

This loop would print forever to the console simple because "print" is indented under the "while" statement.

Help this helps,

Crimson-Deity (author)2010-05-04

I can't get this to work. All I get is a

jimk3038 (author)Crimson-Deity2010-05-04

What error are you getting? What line number does it complain about? Can you capture the error message and post it?

Crimson-Deity (author)jimk30382010-05-05

Thanks for the quick respons ! :D

I have never, ever programmed ANYTHING before so I'm a noob to the max. Could you make a tutorial on how to use Python? I tried to copy and paste the "" content into the IDLE Python text thing, but some sort of error occured. My laptop is somewhere out of my reach at the moment so ill post a picture ASAP.

jimk3038 (author)Crimson-Deity2010-05-05

You have made a good choice with Python as a starting language. Python is kinda like a Swiss Army Knife for programmers. Python can be used to code really simple stuff. Or, full blown object oriented code.

Anyway, step number one - go out and buy two books. Learning Python and Python Cookbook. These are really good to get you jump started. I've attached a picture of my two books. You can see my books are kinda beat up - that is a good sign - means the books are used a lot!

Next, try to run my little code block. I'm guessing your missing the extra serial port package. Python does not have support for serial ports by default. No problem - go back to my instructable and download the extra installer for the serial port package. This package adds serial port control to Python.

Next, run each line of code in IDLE. IDLE will tell you when you hit a problem. But, once you install the serial port package I guessing you won't have any problems.

Good luck,

Swishercutter (author)2009-04-04

I remember when I was in electronics, building a SSR was one of our last projects. Then we had to use our "8088 Primer Trainer" (kit using an 8088 processor to learn to program machine language) to turn on 3 items, a light bulb, a blender and a drill press. So we had to break up into groups of 3 and hook up the hardware to the computer then write the necessary code to turn on one item for 3 seconds then the next and so on. Lots of fun...and we actually built the relays also..if I remember right they were capable of over 20A @ 120V...although its been a number of years.

jimk3038 (author)Swishercutter2009-04-05

SSR are not good on inductive loads like blenders and drill presses. As a plant engineer many years ago, I tried jogging a conveyor belt using a big Crydom SSR relay. I sized the relay to handle the motor and provided a nice heatsink. The relay only lasted one day before failing. Of coarse, the thing failed in the middle of the night too! So, yes, the SSR can be used for a little fun. But don't count on them switching motors for very long!

Swishercutter (author)jimk30382009-04-05

I have no experience with the Crydom or any other manufactured SSR's. Just the ones we built from scratch for educational purposes. I never extensively tested it but it seemed to do just fine. I imagine there may be some issues with the initial current requirements of a large inductive load like a motor (there are ways around that) but they worked in the short term amount of time for our final lab exam. I will have to find the schematic with the part numbers and show how to build one from scratch sometime. Although, I never seem to find the time to actually do an instructable on anything though.

Sandisk1duo (author)jimk30382009-04-05

you could just use a pull-up transistor and a regular relay

cirvin (author)2009-04-04

That's quite a heatsink you have on that SSR. I have a few of these wired up in a steel electrical box with a plug in my dorm to switch a 600 watt lamp, without a heatsink attached. I haven't noticed any appreciable heating of the units. Please comment when you test this out, I'd like to know how your device behaves under your load.

jimk3038 (author)cirvin2009-04-05

The Crydom blocks will get hot when switching heavy loads. The datasheet has a couple of tables that show derating curves based on switching load. Without a heatsink the relays derate to 8 amps at 25 degrees C. So, you should be able to switch up to about 800 watts at room air temperature. In hot ambient temperatures, derate even more down to 6 amps.

However, with a simple heatsink the permissible switching load goes way up. The steel electrical box your using probably would act as a good heatsink. Also, here is a link to a heatsink Crydom makes: As with everything from Crydom, it's pricy (12 bucks at Digikey).

Ten years ago I smoked a big Crydom by not heatsinking it. So now I always make sure they are well sinked. You can also fry a Crydom by switching inductive loads - just a word to the wise.

RazorConcepts (author)2009-04-05

Hmm I found some cheap-no-name brand SSRs on ebay for $7.50 shipped. Will try that out, I looked at the prices on the Crydom relays... WOW

gentry (author)2009-04-05

How much did that SSR cost? I found some 15a Sharp brand ones at digikey for about $5.

gwhamilton (author)2009-04-04

What are the chances of powering the SSR from a USB port? The 5 volt signal should work. I work with SSR's everyday but I need to find a program to switch USB power. Thanks

edwardchen (author)gwhamilton2009-04-04

Pretty easily, you should be able to grab an FTDI type device and just use that as an USB to Serial converter, you should be able to use the TTL serial signal straight from the FTDI to switch the SSR. Other than that, you can follow this instructable for the rest of the instructions.

Swishercutter (author)gwhamilton2009-04-04

Honestly, I know very little about USB programming but since it is a serial connection I would imagine that it would be easy to make a hardware serial to parallel converter with some flip flops on the output set up to drive the relays (not really as simple as I make it sound, but not too bad). By doing this you will not only be able to control power, you will be able to control multiple relays using BCD (Binary Coded Decimal) or something similar to specify which relay is being controlled. With flip flops on the output it makes it so that an item turns on and waits for another signal to turn off (also makes it so you don't have to send a different message to turn off the item, just send the same on message to switch the flip flop).

Berserk87 (author)2009-04-04

cool. i was looking for ways to control high voltage with low voltage things like computers or micro controllers.

servodave (author)2009-04-03

Cool. Best thing about this is that the computer is optically isolated from the ac line. I've built dozens of these for the research lab I work for over the years. SOOOOO Useful for turning things off and on--solenoids, fans, small motors. Usually I put a BNC bulkhead connector on the input and a neon lamp on the output for diagnostics. You might want to add a fuse and some sort of enclosure with vent holes and a fan if you are pushing a lot of power though the relay. Maybe gut an old PC power supply to get the power entry module. Other than that: good show!

About This Instructable




Bio: Founder of Powerhouse Electronics. For more info goto:
More by jimk3038:Easy ESP8266 WiFi Debugging with PythonRaspberry Pi Internet Weather StationMake Your Own Laser Cut Standoffs for Electronic Projects
Add instructable to: