0
\$\begingroup\$

Reopen reviewers: the question didn't ask for a specific product, the question asked for, how to do it. A specific product name may or may not inserted into an upvoted/accepted answer. I had never asked a spam seed intentionally, please don't misinterpret the essential part of the question.

What I can:

  • A home PC with a linux, and I can program it on need.

  • I can buy cheap chinese things from ebay.

  • I can solder and do basic electronic tasks.

What I can't: I won't create printed circuits for a such simple task.

What I want to reach: I want a solution (probably some hw+sw combo), which enabled me to turn on/off the 230V line power of another device by a PC.

I prefered a wired solution against wireless because of stability, but wireless can be also ok.

What to do?

\$\endgroup\$
6
  • \$\begingroup\$ How are you planning to connect your PC to the hardware switch, wired or wireless? I think wireless would be nicer, but a little more complicated. \$\endgroup\$ Apr 25 '14 at 13:06
  • \$\begingroup\$ @TimMottram I prefered wired because of stability, but wireless can be also okay if there isn't better solution. \$\endgroup\$
    – peterh
    Apr 25 '14 at 13:08
  • \$\begingroup\$ Ok, so lets go with wired, what coms protocol do you want to use? I'm guessing USB because that is so common, but you could use serial although its a bit old skool. \$\endgroup\$ Apr 25 '14 at 13:15
  • \$\begingroup\$ @TimMottram Both is okay, I am familiar with rs232 but programming usb also weren't a problem. \$\endgroup\$
    – peterh
    Apr 25 '14 at 13:17
  • \$\begingroup\$ What distance are we talking about? Depending on distance and budget there may already be commericial off the shelf solutions for this. For example, USB and ethernet controlled relays are pretty common. \$\endgroup\$ Apr 25 '14 at 13:17
4
\$\begingroup\$

From what you have said, it sounds like you want a USB mains relay, This will allow you to switch a mains supply on and off from your computer, make sure the relay on the board you buy is rated to your countries mains power format (240V/110V etc..). Such devices can be easily found on ebay or other such sites.

Here is an example:-

http://www.ebay.co.uk/itm/New-1-Pcs-USB-Relay-1-Channel-Programmable-Computer-Control-For-Smart-Home-5V-/201072772365

\$\endgroup\$
10
  • \$\begingroup\$ Or you can have a two channel for less money!! ebay.co.uk/itm/… \$\endgroup\$ Apr 25 '14 at 13:29
  • \$\begingroup\$ Yes, but how can I program this? Will it give some rs232-type interface, or through generic usb ioctl()-s? I can't see any docs about this. \$\endgroup\$
    – peterh
    Apr 25 '14 at 13:37
  • \$\begingroup\$ It comes with a program which will let you use it. \$\endgroup\$ Apr 25 '14 at 13:41
  • \$\begingroup\$ So, I will get some undecipherable window$ thing on a buggy driver cd? I need to transmit a single bit of information: "turn on" or "turn off". How could I bridge this last step? \$\endgroup\$
    – peterh
    Apr 25 '14 at 13:45
  • 4
    \$\begingroup\$ @PeterHorvath Tim has given you a very good answer to your question. You should be thankful, not complaining. If the answer is not what you actually wanted then it's because the question was vaugue and poorly written. \$\endgroup\$
    – Joe Hass
    Apr 25 '14 at 14:40
1
\$\begingroup\$

You only need to control a single digital signal, which can then cause a relay to be turned on or not. However, ordinary PCs don't come with digital outputs you can get at directly. You can either use a different type of PC or connect a small microcontroller to one of the ports the PC does have. You'd then send commands to the micro, which would set a digital output accordingly, which would control a relay.

The common port of a PC that is simplest to connect a micro to is a serial line, or COM port. You need something that converts the RS-232 levels and polarity of the COM port to the UART signals of the micro. Fortunately, there are chips that do just that, such as the common MAX232 or one of its many derivatives. From there it's trivial to write firmware in the micro that interprets bytes sent to it and sets a digital output either high or low.

If the PC doesn't have a COM port, you can use a USB to RS-232 converter, or you could have the micro talk to the PC natively over USB. That's more complicated in software and firmware, but the hardware interface is actually easier. USB can also provide power for the micro directly.

Since you only want a single digital output, there are some possible cheats, like interpreting one of the RS-232 control lines directly by circuitry that drives a relay. That may sound simple and easy at first, but I don't recommend it.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you, this is exactly which I found until now. And this "simple" problem is what needs a solution now. \$\endgroup\$
    – peterh
    Apr 25 '14 at 13:37
1
\$\begingroup\$

As long as the relay circuit just need a digital signal, this is not complicated to do. Most usb to rs232 allows you to set their dtr or rts line to either high or low. Most of the programming languages nowadays should allow you to manipulate the rts and dtr by just setting a boolean value - With this you dont need a microcontroller. Depending on the levels those rts dtr give (some cheapo usb to rs232 gives 0 to 5v swing - take note, dont confuse them with usb to ttl converters - while some will give you the ideal 10 to -10v swing). I will still use an optocoupler and compute the series resistor and then add a reverse diode protection, better safe than sorry.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you! Ok, suppose I can control one of the rts or dtr pins. How could it control a 230V power network switch? \$\endgroup\$
    – peterh
    May 12 '14 at 8:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.