Control a USB light via software
Asked Answered
A

8

11

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.

Abib answered 26/8, 2010 at 20:41 Comment(5)
If you had a parallel port, then controlling it would be very easy, although not the most energy efficient way of doing stuff.Itself
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?Abib
Try this :) dlink.com/category/productcategories/?cid=83Itself
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?Abib
I’m voting to close this question because it's about electronics, not about software.Ludovico
A
1

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.

Abib answered 27/8, 2010 at 15:28 Comment(0)
O
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.

Ouphe answered 26/8, 2010 at 21:28 Comment(4)
+1 DigiKey is a damn good resource for serious electrical/computer engineering.Itself
This looks cool. I think that my current USB/serial bridge may be able to help me here. I have a [PL-2303 ](prolific.com.tw/eng/products.asp?id=59) USB/serial adapter. Think that'll do it?Abib
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.Abib
You can use, for example, PyFtdi to control the signals.Gronseth
C
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.

Cadmarr answered 26/8, 2010 at 20:44 Comment(3)
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.Abib
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.Cadmarr
Yeah! I think you're mostly right, but 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.Abib
G
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.

Grilled answered 26/8, 2010 at 20:46 Comment(1)
I don't think I can do that. Especially if the device is dumb.Abib
A
1

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.

Abib answered 27/8, 2010 at 15:28 Comment(0)
D
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!

Darlleen answered 28/2, 2013 at 9:42 Comment(1)
How to do this in Windows 8, 10?Beachhead
B
1

Technically this does not answer your question, but rather proposes an alternative.

I just found BlinkStick. They sell a USB RGB led (open hardware) along with an open source API library that allows you to control it by code.

It uses as controller an ATTiny85 with firmware based on V-USB that you can build yourself (schematics are available). Then by downloading the application it exposes an API compatible with quite some programming languages.

Bookplate answered 15/9, 2023 at 12:5 Comment(3)
any affiliation? /help/promotionShulamite
I have nothing to do with them. I was casually looking on the internet an RGB led by USB I could control from Node-Red and change color based on polling a Scada OPC-UA server.Bookplate
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Tongue
M
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.

Meshwork answered 28/8, 2010 at 14:56 Comment(1)
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. :)Abib
D
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.

Discretionary answered 22/4, 2021 at 18:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.