• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

Request for information: Software-controlled Relay switch

Segnosaur

Penultimate Amazing
Joined
Jan 18, 2002
Messages
21,807
Location
Canada, eh?
I'm just wondering if someone with more hardware experience can point me towards either a store, or a particular product. (Hopefully this isn't too commercial of a request for this forum.)

What I am looking for: I want a simple single relay switch (probably mechanical) that can be connected to a computer (preferribly though the USB port.) The relay doesn't necessarily need to handle very high voltages and current (12V maximum). The computer itself can be Windows or Debian Linux (and it needs to work with both).

I also need to be able to control the relay through software that I'll be writing (in C).

I've done a few searches on line and found a couple of possibilities, but none of them seem to mention being able to program them.

Anyone have any recommendations?
 
I used to be the quality control supervisor for a company that manufactured tanning beds. I actually built a very simple tester that used a computer controlled 5v relay to turn the beds on and off numerous times. It was pretty easy to build.

I wired the 5v relay to the first data pin of a DB-25 parallel port connector. Then I used a few lines of machine code to send data directly to the pins..like:

mov dx, 378h
mov al, 00000001b
out dx, al ; output

I used the machine code as a function in "c", so I could call on that function when ever I needed to turn the bed on or off within the program.
 
Look on eBay for Arduino. These are little microprocessor boards that connect to a PC using a USB cable and can be programmed with a free IDE using, basically, C, or C++

They have a virtual serial port built in so you can communicate with them from your PC program.

There are loads of available modules to fit the Arduinos - all dirt cheap. What you need is a relay module so search for 'arduino relay module'

You'll probably pay around $4 for an Arduino Uno or Nano clone and about the same for the relay module. The Uno model is the one most beginners start with and if you get a relay 'shield' module it will plug straight on to the Uno so you won't have to do any wiring up. The Nano is smaller and more breadboard friendly if you're used to breadboard when tinkering with electronic prototypes. If you go for the Nano you'll have to wire it up to the relay module which may include some soldering, depending on what modules you buy. Either solution will just be bare circuit boards so you'll probably eventually want to put the parts in a case of some kind - but you can usually adapt some old food container or other plastic packaging for that purpose.

The Arduino can, of course, be equipped with a display, push buttons and so on and then run as a stand alone gadget, but it's also probably the cheapest way for someone who knows C to build a simple PC hardware peripheral.
 
Last edited:
Look on eBay for Arduino. These are little microprocessor boards that connect to a PC using a USB cable and can be programmed with a free IDE using, basically, C, or C++

They have a virtual serial port built in so you can communicate with them from your PC program.

There are loads of available modules to fit the Arduinos - all dirt cheap. What you need is a relay module so search for 'arduino relay module'

You'll probably pay around $4 for an Arduino Uno or Nano clone and about the same for the relay module. The Uno model is the one most beginners start with and if you get a relay 'shield' module it will plug straight on to the Uno so you won't have to do any wiring up. The Nano is smaller and more breadboard friendly if you're used to breadboard when tinkering with electronic prototypes. If you go for the Nano you'll have to wire it up to the relay module which may include some soldering, depending on what modules you buy. Either solution will just be bare circuit boards so you'll probably eventually want to put the parts in a case of some kind - but you can usually adapt some old food container or other plastic packaging for that purpose.

The Arduino can, of course, be equipped with a display, push buttons and so on and then run as a stand alone gadget, but it's also probably the cheapest way for someone who knows C to build a simple PC hardware peripheral.
And you would be correct.

Many years ago before USB existed, I custom built such a thing working off the parallel printer port (remember those?). Things like Arduino have rendered such custom builds unnecessary unless done for fun.
 
https://denkovi.com/usb-relay-board-four-channels-for-home-automation-v2

I haven't used them myself, but I know people who have, and I think this is what you're looking for, unless you have specific mechanical/packaging requirements. The company has a couple of variations.I don't think they have a 1 relay variant, though. If you don't mind hanging out with three other relays, it will work.


I have used a lot of products from measurementcomputing.com, but they tend to be more expensive, and I don't know if they have Linux support.
 
Last edited:

Back
Top Bottom