What's new

Control the USB Power supply (on/off) with commands

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Yota

Very Senior Member
Many people have asked how to control the asuswrt USB power supply with commands? now I found the way.

Well, the simple answer is:
Use the hub-ctrl

Help documentation
Code:
/tmp# hub-ctrl --help
Usage: hub-ctrl [{-h HUBNUM | -b BUSNUM -d DEVNUM}] \
          [-P PORT] [{-p [VALUE]|-l [VALUE]}]
Examples:
 *   # hub-ctrl -v                 // List hubs available
 *   # hub-ctrl -P 1               // Power off at port 1
 *   # hub-ctrl -P 1 -p 1          // Power on at port 1
 *   # hub-ctrl -P 2 -l            // LED on at port 2


How do I find it
Just ready to write a script that wants to control the fan by controlling the USB power supply. but, searched the forum and Google didn't find it.
However, this thread helped me, and after testing some commands, I found it. this command should work on both stock and merlin firmware.

Usage example
You can use a simple script to control USB fan on and off, like this:
Code:
#!/bin/sh
# Turn the fan on above 100 celsius, else turn it off.
# NOTE: Different models have different temperature commands.
if [ "$(cat /sys/class/thermal/thermal_zone0/temp | sed 's/.\{3\}$/.&/')" -ge "100" ]; then
   hub-ctrl -P 1 -p 1
else
   hub-ctrl -P 1
fi
Don't forget to create a scheduled task, like this:
Code:
# Run your script every 30 minutes.
cru a CTRLUSB "*/30 * * * * /jffs/scripts/your_script"

Enjoy!


References
User scripts asuswrt-merlin
Scheduled tasks (cron jobs) & Scheduled Reboot
Command to get the correct temperature value by sfx2000
Power on/off USB ports on hubs with hub-ctrl from the openwrt forum
Toggling USB subsystem via ssh from the dd-wrt forum
 
Last edited:
Interesting. Just to clarify for anyone else reading who's interested in this, you need to install hub-ctrl via entware.
Code:
opkg install hub-ctrl

Sent from my Nokia 7 plus using Tapatalk
 
Interesting. Just to clarify for anyone else reading who's interested in this, you need to install hub-ctrl via entware.
No, you don't need that, it is built into the firmware, maybe from 380, and even in stock firmware, I have tested it.;)

Edit: Just looking at the source code, it has been in the firmware for 7 years, I can't believe it has never been found.
 
Last edited:
Wow! Awesome new direction, and thanks for the other thread!

I'm thinking less about fans than a hard disk that I could power on, mount and spool up for access on command, from afar. Electric cost of keeping it running around $10/year.

On the fan thing, I had hooked up my 87U, suffering from heat issues, to a pair of infinity fans to blow across (electric cost maybe around $2/year), and then instead put a 5v fan into the cover over the 5Ghz chip and wired to one of the serial pegs; works fine without the infinity fans (electric cost I think maybe around $.50/year). Maybe the hole in the cover was enough. But the fan control thing is still iffy in priority.
 
Perfect!
AC86U doesn't have LEDs on USB ports, as I know, so the output of hub-ctrl -P 2 -l was
Code:
failed to control.
: Resource temporarily unavailable

Port 1 should be USB 3.0 and port 2 USB 2.0?

And on this router specificaly, I think 100º is very high. Router is almost always around 70º. Should I activate the fan on which ºC?
 
I'm thinking less about fans than a hard disk that I could power on, mount and spool up for access on command, from afar. Electric cost of keeping it running around $10/year.
Do not use this command, because it may destroy your hard drive and may corrupt data.

You should always use the mount command for hard drives, like this:
Code:
# Check the disk name
df -h
# Unmount the disk
umount /tmp/mnt/diskname
# Remount the disk
mount /dev/devicename /tmp/mnt/diskname
Learn more:
Disk formatting
EXT4 disk formatting options on the router by Zonkd


AC86U doesn't have LEDs on USB ports, as I know, so the output of hub-ctrl -P 2 -l was
Even if there is an LED, the command does not work for me, because asus controls the LED with other command, like this:
Code:
# led_ctrl lednumber state
# define LED_USB                         1
# define LED_USB3                        9

# USB 2.0 LED Off Example:
led_ctrl 1 0
Learn more:
Scheduled LED control
User scripts upon button press and LEDs by RMerlin

Port 1 should be USB 3.0 and port 2 USB 2.0?
I think different models have different ports, thanks for your testing.
And on this router specificaly, I think 100º is very high. Router is almost always around 70º. Should I activate the fan on which ºC?
Asus technical staff once told me that there is no need to worry about 100 ºC and the router above 100 ºC will automatically take proactive measures. (Maybe it will automatically downclock? IDK)


Enjoy, guys!;)
 
Last edited:
Do not use this command, because it may destroy your hard drive and may corrupt data.

You should always use the mount command for hard drives, like this:
Code:
# Check the disk name
df -h
# Unmount the disk
umount /tmp/mnt/diskname
# Remount the disk
mount /dev/devicename /tmp/mnt/diskname
Learn more:
Disk formatting
EXT4 disk formatting options on the router by Zonkd



Even if there is an LED, the command does not work for me, because asus controls the LED with other command, like this:
Code:
# led_ctrl lednumber state
# define LED_USB                         1
# define LED_USB3                        9

# USB 2.0 LED Off Example:
led_ctrl 1 0
Learn more:
Scheduled LED control
User scripts upon button press and LEDs by RMerlin


I think different models have different ports, thanks for your testing.

Asus technical staff once told me that there is no need to worry about 100 ºC and the router above 100 ºC will automatically take proactive measures. (Maybe it will automatically downclock? IDK)


Enjoy, guys!;)
Afaik above some temperature the router disables core and enables it once temperature is down again. I read somewhere during a Google search.
And of temperature doesn't go down, it reboots the router (but downclock is a very good guess)
 
Afaik above some temperature the router disables core and enables it once temperature is down again. I read somewhere during a Google search.
And of temperature doesn't go down, it reboots the router (but downclock is a very good guess)

Asus customer service told me don't connect a usb fan to the router, as this could cause the router to overload and even damage the capacitors.
But I think they will no objection to using a phone adapter to power the fan.
 
Last edited:
Overload? Does a thing USB fan consumes so much power?!
 
Overload? Does a thing USB fan consumes so much power?!
I don't think so, maybe asus just doesn't want people to break their routers.

In fact, asus even suggested using the usb port to charge the iPad when marketing, but now they have removed all the hints on the official site about this.

But you can still see it in the user manual files.
 
Last edited:
I don't think so, maybe asus just doesn't want people to break their routers.

In fact, asus even suggested using the usb port to charge the iPad when marketing, but now they have removed all the hints on the official site about this.

But you can still see it in the user manual files.
I bought some USB fans through eBay. When I receive it, I'll test the power they need with a little tester I have to see if they consume more than an iPad :)
 
The 87U supposedly has 1500mA and 1750mA from the USB2 and USB3 ports.
 
Today my fans arrived and i've been testing.
None of the codes work... USB doesn't power off or on.
 
Today my fans arrived and i've been testing.
None of the codes work... USB doesn't power off or on.
Sorry for the late reply.
I don't have an RT-AC86U for testing, but I think it can work normally because my friend reported that it worked well.

Please use the code below to check the USB interface being used, because sometimes they may be different.
Code:
hub-ctrl -v
And then test if it works
Code:
hub-ctrl -P $your-usb-port
Hope to hear the good news :)
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top