9

I have a little USB-powered light. I'd like to be able to turn it on and off with software. I'll be attaching it to a Linux computer. I have an Atmel ATtiny2313 from a previous project, but I'd rather do this with a simple hack than repurpose my microcontroller.

Is this possible? I suspect this can't be done as the computer won't talk to a device without some kind of USB-compliant firmware?

I found this question, which has a comment suggesting that the OP use an LM317 voltage regulator to change the voltage of the USB out. I don't think this is applicable to me, but thought I'd mention it.

Update:

Looks like I could maybe put USBtiny on my microcontroller, then I could wire it up to the light, then I could write an app to control the controller. Sounds like a lot of work, though. I'd rather do a simple hack, but I lack experience with USB.

Community
  • 1
  • 1
Justin Force
  • 6,203
  • 5
  • 29
  • 39
  • If you had a parallel port, then controlling it would be very easy, although not the most energy efficient way of doing stuff. – Hamish Grubijan Aug 26 '10 at 21:19
  • Because parallel was 5V, right? Unfortunately, this computer is very new and only has USB. I also have a USB serial adapter... Hmmmm... maybe software -> USB -> serial adapter -> light? – Justin Force Aug 26 '10 at 21:25
  • Try this :) http://www.dlink.com/category/productcategories/?cid=83 – Hamish Grubijan Aug 26 '10 at 21:38
  • I haven't really used PoE. I think that the price would likely be unreasonable for the scale of this project, but it's interesting. Can you just turn power on and off to individual ports? – Justin Force Aug 26 '10 at 21:51
  • I’m voting to close this question because it's about electronics, not about software. – TomServo Apr 30 '21 at 02:07

7 Answers7

3

Your best bet is probably to buy something like an FTDI interface cable, available from Digi-Key for $20. That gives you +5, ground, and four wires you can switch high or low under software control. The software's easiest if you use the thing as a logic-level serial port with rx/tx/rts/cts. The manufacturer part number is TTL-232R-5V-WE (go to digikey.com and type that number into the part search box). Digi-Key has links to the manufacturer data sheets and web site.

supercat
  • 77,689
  • 9
  • 166
  • 211
  • +1 DigiKey is a damn good resource for serious electrical/computer engineering. – Hamish Grubijan Aug 26 '10 at 21:39
  • This looks cool. I think that my current USB/serial bridge may be able to help me here. I have a [PL-2303 ](http://www.prolific.com.tw/eng/products.asp?id=59) USB/serial adapter. Think that'll do it? – Justin Force Aug 26 '10 at 22:14
  • I appreciate your suggestion and +1 it, but it doesn't really answer my question. Thanks for the DigiKey and FTDI tips, though! I especially appreciate the part number. – Justin Force Aug 27 '10 at 15:29
  • You can use, for example, [PyFtdi](https://eblot.github.io/pyftdi/installation.html) to control the signals. – Patrick May 31 '22 at 12:08
2

I don't think it is possible, because the power (Vcc) line on USB is always-on--it is not intended to be a control line.

Unless your USB light already provides a way to control itself via USB data, you are out of luck. I do not recommend trying to change the voltage of the USB power line.

Patrick Szalapski
  • 8,738
  • 11
  • 67
  • 129
  • But can I manipulate the data output from the computer and use that as input to a transistor or microcontroller? Then I can control whether to let the 5V through to the light. I just don't know if I can manipulate the data pins on the USB port if the device on the other end isn't a legitimate USB device. – Justin Force Aug 26 '10 at 21:05
  • So you would shunt the data lines on the usb port to your own microcontroller? I suppose there is a way, but then you'd have to learn the USB hardware layer and how to write a driver for it. – Patrick Szalapski Aug 27 '10 at 15:29
  • Yeah! I think you're mostly right, but [USBtiny](http://www.xs4all.nl/~dicks/avr/usbtiny/) should fit on my microcontroller, and should fill this role for me. I'm probably going to learn the USB hardware layer anyway for fun. – Justin Force Aug 29 '10 at 18:58
1

I guess this could be possible using the computer's ability to switch on/off the USB ports to save battery. After a surprissingly short search I found another question regarding that:

Controlling a USB power supply (on/off) with linux

Though I have not tried it. Please let us know if it worked!

Community
  • 1
  • 1
viridis
  • 177
  • 10
1

Maybe you can tell the USB controller to cut off power to the USB port. I've seen this option on the power saving settings on my PC.

0

I'm going to use my PL-2303-based USB/serial bridge and an ATtiny2313 microcontroller running a USB stack--possibly USBtiny. It'll work like this:

  • The USB light is attached directly to the microcontroller--not the computer
  • An app/driver controls the microcontroller via USB
  • The microcontroller sets the voltage for the USB light

I'll look into wiring it so there are some resistors on some outputs so I can set the light to different brightnesses, and if I want to do patterns or anything, I'll do them in software.

Justin Force
  • 6,203
  • 5
  • 29
  • 39
0

Would it be possible to rewire the usb connector so that instead of being connected to VCC the power of the usb light would be connected to the data of the usb port?

Then maybe you could control that and specify if it was 0 or 5 volts.

Not sure if that's even possible, I know nothing about usb.

  • I considered this, but I doubt I'll be able to talk to the data wire of the USB port if the device at the other end isn't doing USB communication. I also know very little about USB. I think I'll know quite a bit by the end of this project, though. :) – Justin Force Aug 28 '10 at 19:13
0

USB is a universal bus that required drivers and a description of how to work with it. It has greater flexibility, but same time all logic should be stored somewhere (drivers/app/etc) and this is not easy "scalable" such as Windows, Linux, Phone, etc... all required different apps and manages... And unfortunately, it's no way to enable/disable USB locally (like manage outgoing power, since mostly it's managed on BIOS level, which is not fully available from OS level - actually check your Mother Board if it's supporting IPMI - it's a management tool which works on the lower level, but mostly available only on Server type of hardware)


I have similar needs of turning on/off light, but more for indication. My use case: we have an office with sales, support, etc... calls are not often, but when they are in place it's better to keep being quiet. And since people are using the same headsets for listening to music - from the side you can't understand if the call is in progress or not...

So, the idea is:

  • Arduino (later can be optimized for something cheaper)
  • WIFI connection
  • LED light (5V ideal, but might be 12V)
  • Power from a power adapter or maybe USB (later can check if the battery is making sense)
  • Management done via a web browser (simplifying management such as - can be done via Chrome Extension, button on the web-page, remotely managed from (in my case) phone system)

If all will be good - some centralized management can be added on top (all light can be registered in the system (such as WebSocket for example, or google pub/sub for centralized management). In this case, it can be triggered remotely by a phone system in a centralized way, such as: if incoming call - light can start blink to get attention when the call is in place and automatically turn on when the call in place... plus can be done the similar way for Google Meeting, Zoom, any other app on the computer)

PS: will be good to find anything ready-to-go like that... but oh, well - for now nothing has been found.

Priyank_Vadi
  • 1,028
  • 10
  • 27