Justin Force
Justin Force

Reputation: 6342

Control a USB light via software

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.

Upvotes: 11

Views: 13734

Answers (8)

maximusboscus
maximusboscus

Reputation: 37

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.

Upvotes: 1

artickl
artickl

Reputation: 11

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.

Upvotes: 0

viridis
viridis

Reputation: 177

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!

Upvotes: 1

dioltas
dioltas

Reputation: 1

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.

Upvotes: 0

Justin Force
Justin Force

Reputation: 6342

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.

Upvotes: 1

supercat
supercat

Reputation: 81115

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.

Upvotes: 3

user180326
user180326

Reputation:

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.

Upvotes: 1

Patrick Szalapski
Patrick Szalapski

Reputation: 9439

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.

Upvotes: 2

Related Questions