USB-controlled power switch

Hey guys :slight_smile:
Noob here. I have experience with programming and basic electronics, but I've never worked with Arduino.
I wanna build a USB device, but I don't yet know how exactly to do it, so I need your help.

Basically, what I want to build is a USB-controlled electronic "switch" of sorts.

I have this other expensive USB device (which I can't afford to get rid of) that sometimes gets stuck in some undefined firmware state and malfunctions, and the only way to reset it is to literally cut off its power (by unplugging and plugging it back to the computer).
My idea is to create some sort of simple Arduino USB-controlled device that would contain inside itself some kind of electronic switch (relay? MOSFET?), through which I would pass the expensive-but-malfunctioning device's USB cable - so that I could automatically send some kind of signal from my computer to the Arduino device to make it cut off the expensive-but-malfunctioning device's power and turn it back on.

Is this feasible?
If so, can anyone give me some general guidelines on how to do it, or at least the set of sufficient electronic components that would make this possible?
From what I've searched on the internet, the Arduino devices for sale in my city are the following (quoting seller's site):

  • ARDUINO UNO R3 328P
  • ARDUINO MODUL BOARD ECG AD8232 EKG
  • ARDUINO UNO SMD CHIP (023062)
  • Arduino UNO SMD Chip HX41E011

Note that I'm a total noob and don't quite understand the whole structure of Arduino - what does what, what is needed for what... so please be verbose and detailed. I'm willing to put in blood and sweat, as making this is really important to me :slight_smile:

Thanks!

Yes... You can control a relay with the Arduino* and the Arduino can read the USB "serial port" to respond to a message or command. See [u]Read ASCII String[/u].

But, do you really need to control the relay with the computer? You'd have to write software for the computer AND for the Arduino.

and the only way to reset it is to literally cut off its power (by unplugging and plugging it back to the computer).

Would a manual switch or pushbutton be OK? You could cut-open a USB cable and wire a switch/button in series with the power wire.

You'd need to use an Ohmmeter or continuity tester to identify the power wire, and you might end-up cutting all 4 wires and re-splicing 3 of them. (USB-3 has more wires.) If you get a momentary pushbutton it needs to be SPDT (or DPDT) so you can use the normally closed (normally "on") connections.

  • The Arduino can't directly drive a relay so you need a little transistor or MOSFET driver circuit or you can buy a relay board with a driver & relay built-in.

DVDdoug:
But, do you really need to control the relay with the computer? You'd have to write software for the computer AND for the Arduino.
Would a manual switch or pushbutton be OK? You could cut-open a USB cable and wire a switch/button in series with the power wire.

Yes, I really need to control the relay with the computer. The expensive-but-malfunctioning device is going to be deployed on a remote location with no physical access, and I need to be able to restart it automatically without human intervention.

Is it possible to do this with an Arduino UNO R3 Atmega 328p CH340 and a relay that looks like the image I attached?
If so, do I need any other equipment? Any wires, cables and stuff?

bheadmaster:
Yes, I really need to control the relay with the computer. The expensive-but-malfunctioning device is going to be deployed on a remote location with no physical access, and I need to be able to restart it automatically without human intervention.

Is it possible to do this with an Arduino UNO R3 Atmega 328p CH340 and a relay that looks like the image I attached?
If so, do I need any other equipment? Any wires, cables and stuff?

Yes, you need a 5 volt DC power supply for the Arduino and for the relay module. If you run the Arduino from the PC USB 5 volts, then you still need the separate 5 volt supply for the relay module.

Wires, cables, stuff, are all up to you and your installation. I can't see it from here.

Paul

Does the badly behaving USB device do anything, or fail to do anything, that indicates it needs to be reset? If there's a dependable test of some kind that the Arduino could carry out, then you could make the reset happen automatically and not need to do anything remotely.

Also, if you can get inside the device, it might be possible to reset it rather than power cycle it, so you wouldn't need a relay.

If you're at liberty to give us more information on the device, it might help.

ShermanP:
Does the badly behaving USB device do anything, or fail to do anything, that indicates it needs to be reset? If there's a dependable test of some kind that the Arduino could carry out, then you could make the reset happen automatically and not need to do anything remotely.

The badly behaving USB device simply stops sending the data that it needs to send, and the system calls that communicate with the USB drivers fail with a timeout. That's the only indicator, but it can be properly detected at runtime by the software using the badly behaving device. Power cycle is the only thing I have found that helps.