2
\$\begingroup\$

I just bought a 5 volt dual relay module for my arduino. But now that I have it I was wondering if there is any way that I could control it directly from USB.

The pinout of the module is GND ONE TWO VOC This would make it really easy to just connect a USB cable to it.
Assuming I did that is there any way to send 5 volt through the USB Data+ and Data-?

Thank you

\$\endgroup\$
1
  • 6
    \$\begingroup\$ Data+ and Data- are a differential signal pair, and you should NEVER try and put any sort of load on them. \$\endgroup\$
    – Jonathon Reinhart
    Jun 19, 2012 at 17:02

2 Answers 2

10
\$\begingroup\$

Basically, NO. USB is a complex protocol, and there is no direct way to control the D+ and D- lines (your ONE and TWO) from software. You can only cause the USB stack to send certain messages, embedded somewhere in a stream of other messages.

But you MIGHT be able to switch the power to the USB port (your GND and VOC)off and on under software control. Most laptops can do this in some power down mode, so there might be a way. Don't ask me how, I am not a PC guru. The catch will probably be that you switch the power to ALL USB ports, including your mouse and keyboard...

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I did it once on Linux. I was able to turn off and on a device on a USB port, but it wasn't really trivial to find the exact right file in /sys or /proc and while searching for it couple of weeks ago I couldn't find it any more :( \$\endgroup\$
    – jippie
    Jun 19, 2012 at 19:14
  • 1
    \$\begingroup\$ Switching power may be possible, but this depends on the PC. Laptops often actively control USB power because their power budget is so limited. I have seen desktop motherboard schematics where the USB power came straight from the system +5 V line with only a polyfuse in between. On those systems it would be impossible to switch the USB power from software. \$\endgroup\$ Jun 20, 2012 at 11:46
2
\$\begingroup\$

As jippie said it's possible to turn a USB port power on and off in linux, here and here, as for windows, I have no idea but doubt it's possible.

\$\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.