I have a USB device I want to turn off and on via a Pi or NodeMCU device. I tried the trick “echo 0 > /sys/devices/platform/soc/20980000.usb/buspower” on the PiZero, but it didn’t work.
Could someone suggest a component or software solution to be able to turn on/off a USB power source? I could build something for 5v and wire a USB cable, but I had hoped there was something already out there.
John,
I have to ask Why? Is the USB used just to provide power or something else? If it’s just power, hack the lead from a USB charger and put a relay in it.
Thanks. This would work, but I’d need to have a think about how to wire in USB ports. I don’t want to cut the USB cables for the devices I want to switch on/off.
Great suggestion Dave! Before this conversation I wasn’t aware that there was a way to remove power from a USB port via software.
John, I would take a USB hub and wire that up to the relays for power, then you could shut your devices off without compromising the original USB cords.
Interesting… The bind/unbind work on the Pi3B+. Cool.
Unfortunately, it turns off ALL usb ports and ethernet.
To shut off power on USB ports (this shuts power on ethernet as well): echo ‘1-1’ |sudo tee /sys/bus/usb/drivers/usb/unbind
To turn power back on echo ‘1-1’ |sudo tee /sys/bus/usb/drivers/usb/bind
I have no idea what this ‘bind’ and ‘unbind’ are doing…
-John
1 Like
And you can get our latest projects and tips straight away by following us on: