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\$
9
  • \$\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\$
    – Tim M
    Commented Apr 25, 2014 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
    Commented Apr 25, 2014 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\$
    – Tim M
    Commented Apr 25, 2014 at 13:15
  • \$\begingroup\$ @TimMottram Both is okay, I am familiar with rs232 but programming usb also weren't a problem. \$\endgroup\$
    – peterh
    Commented Apr 25, 2014 at 13:17
  • 1
    \$\begingroup\$ @peterh this question is too broad, please ask a specific question if where you are stuck in your design. I would suggest you use an off the shelf relay exploringarduino.com/parts/ac-relay \$\endgroup\$
    – Voltage Spike
    Commented May 28, 2022 at 14:57

4 Answers 4

3
\$\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\$
    – Tim M
    Commented Apr 25, 2014 at 13:29
  • 2
    \$\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
    Commented Apr 25, 2014 at 13:45
  • 1
    \$\begingroup\$ It isn't o.k., I need not the program, I want to know, what should I put in the usb line to turn this on, or turn this off. This documentation is what I need. \$\endgroup\$
    – peterh
    Commented Apr 25, 2014 at 13:53
  • 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
    Commented Apr 25, 2014 at 14:40
  • 1
    \$\begingroup\$ @TimMottram This is a link-only answer. The problem with external links is that the pages move, the links die, and your post stops being useful in the long run. This is even more of a problem when the link goes to eBay. Such links perish quickly and certainly, because eBay auctions expire. You can easily include a couple of images and the 1-line description into the body of your post. \$\endgroup\$ Commented Sep 30, 2014 at 19:19
2
\$\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
    Commented Apr 25, 2014 at 13:37
2
\$\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
    Commented May 12, 2014 at 8:12
0
\$\begingroup\$

Now, 8 years later, I already can say more about the topic. I still don't have a device for the task, but I already have the knowledge to give a much better self-answer.

This question was too broad (and also hardware recommendation) in the eyes of a professional electronics engineer. It is a very obvious and on-topic question in the eyes of an educated layman (what I count myself in EE things).

What is sure in the solution, that it needs a relay. Like this:

enter image description here

(It was the first image result googling for "230v relay"). That can turn on/off a 230V current, using some low current (most probably 5V today).

However, this still needs that input 5V, what we need to turn on/off from a simple linux PC or laptop programmatically.

Here comes yet another huge disadvantage. While electrical engineers love the RS232, a software developer has nightmare from RS232. That is because they see the world a layer higher.

This dissent is very characteristic and very strong, yet it is surprisingly unknown, except those who know both worlds well. This is why the hacky RS232s are good solutions for electrical engineers, but they are completely unfeasible for a linuxer developer, like me. (So I voted up that answer, but I did not what it suggested.)

Back to the problem, so we need an 5V port what we can turn on/off programmatically, and then we need to connect it to a relay. That can happen by a GPIO (general purpose input/output). Ordinary laptops have no such things.

Googling for things like simply usb controllable GPIO boards, they exist. That is an option. The USB control of EE things is being done typically over:

  1. An emulated RS232 (what is loved by electrical engineers, but causes nightmare for software developers).
  2. Over USB HID. In theory, it is a general USB protocol to handle human IO (keyboard, mouse and so). In practice, it became a generic "thing handler" over USB. You just plug in the thing and then you can turn in/out things by writing into device files below /dev/usb. (Windowsers have their driver CDs as usual.) This is what I want.

Another way is to get some microcontroller (they have typically a lot of GPIO ports) and use them to control this single GPIO bit on a devboard. This is more work, more costly but also much more flexible (for example, most SoC today has integrated wifi and similars).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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