January 24, 2011

Use Linux to control power outlet via USB

Much of information on this page is based the web page at here

1. buy EcoStrip , and Linksys USB2HUB4 USB 2.0 hub. This hub supports power control. Internally it uses NEC chipset.

2. Download hub-ctrl.c, OR download it at this site

3. Use lsusb utilities with -v option, you can inspect 'Hub Descriptor', such like:
Hub Descriptor:
     wHubCharacteristic 0x0089
       Per-port power switching
       Per-port overcurrent protection
       Port indicators

4.compile hub-ctrl.c with -lusb (you need to install libusb-dev if you don't have it)

5. run "sudo ./hub-ctrl" to list the possible hub that supports power control
Bus 002 Device 003: ID 0409:0058 NEC Corp. HighSpeed Hub
Bus 002 Device 002: ID 8087:0020
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0020
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub 
6.From above, you can see that my Linksys hub is located at Bus 2 Device 3. So I use the following command to turn the ecoStrip (which is plugged into the Linksys Hub port 1) power off:

sudo ./hub-ctrl -b 2 -d 3 -P 1 
And the following command to turn it on

sudo ./hub-ctrl -b 2 -d 3 -P 1 -p 1


  1. Hi,
    Those hubs are not anymore available in the market. Do you have an hub suggestion that is currently available?

  2. You can buy the "USB NET Power 8800" from amazon. There is Linux and Windows program to control it.

  3. "USB NET Power 8800" seems a really good product. However in my case I really need an usb hub because I want to connect usb devices to the hub. Do you have another great suggestion? ;)

  4. If you're reading this and you know of a still-sold hub that can do per-port power switching with hub-ctrl.c -- post the manufacturer and model and revision! Please!

  5. I can confirm this one works:
    You can actualy see 2 hubs, the second one is controlled by the 4th port of the first one.

  6. Is it possible in my this hub

    Ganged power switching
    Ganged overcurrent protection
    TT think time 8 FS bits
    bPwrOn2PwrGood 50 * 2 milli seconds
    bHubContrCurrent 100 milli Ampere
    DeviceRemovable 0x00
    PortPwrCtrlMask 0xff

    even cut off whole hub power for few second please advice thank you ..

  7. Works with B&B Electronics 2 Port USB Isolator UHR-402