-
- Posts: 71
- Joined: Tue Oct 30, 2012 10:44 am
Raspberry Pi B+ turn usb power off
Hi all,
Does anyone know if there is a command (or some way in software) to turn off the power for any of the attached USB devices on the Raspberry Pi B+?
Does anyone know if there is a command (or some way in software) to turn off the power for any of the attached USB devices on the Raspberry Pi B+?
- DougieLawson
- Posts: 42772
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: Raspberry Pi B+ turn usb power off
There isn't.
Use an in-line hardware switch.
Use an in-line hardware switch.
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
- Paul Webster
- Posts: 871
- Joined: Sat Jul 30, 2011 4:49 am
- Location: London, UK
Re: Raspberry Pi B+ turn usb power off
This might be enough (all USB off - including the built-in Ethernet)
Disable
echo 0x0 > /sys/devices/platform/bcm2708_usb/buspower
Enable
echo 0x1 > /sys/devices/platform/bcm2708_usb/buspower
Disable
echo 0x0 > /sys/devices/platform/bcm2708_usb/buspower
Enable
echo 0x1 > /sys/devices/platform/bcm2708_usb/buspower
- mahjongg
- Forum Moderator
- Posts: 15100
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: Raspberry Pi B+ turn usb power off
the PI (B+) has NO hardware in place to disconnect power to the USB ports!
it can detect a short, (USB power Fault) and then the USB power controller (P2553W6) will automatically block the USB power, but the PI cannot turn off the USB power using software. What it can do is bring the LAN9514 into sleep mode, but that does NOT turn the power off!
post edit, I learned the designers used a hack, so that the same signal that monitors an overload status can also be used to disable the power monitor, thus shut off USB power, so by previous remark was incorrect!
Its a single current monitor, so shutting it down affects all USB ports.
it can detect a short, (USB power Fault) and then the USB power controller (P2553W6) will automatically block the USB power, but the PI cannot turn off the USB power using software. What it can do is bring the LAN9514 into sleep mode, but that does NOT turn the power off!
post edit, I learned the designers used a hack, so that the same signal that monitors an overload status can also be used to disable the power monitor, thus shut off USB power, so by previous remark was incorrect!
Its a single current monitor, so shutting it down affects all USB ports.
Re: Raspberry Pi B+ turn usb power off
Yes it can.mahjongg wrote:the PI (B+) has NO hardware in place to disconnect power to the USB ports!
it can detect a short, (USB power Fault) and then the USB power controller (P2553W6) will automatically block the USB power, but the PI cannot turn off the USB power using software. What it can do is bring the LAN9514 into sleep mode, but that does NOT turn the power off!
Issuing a USB Hub class request (CLEAR_FEATURE PORT_POWER) to port 2 on the LAN9514 will deactivate the USB output power switch.
There's an app for that:
https://github.com/codazoda/hub-ctrl.c
Rockets are loud.
https://astro-pi.org
https://astro-pi.org
-
- Posts: 1593
- Joined: Fri Jan 04, 2013 1:57 pm
- Location: de_DE
Re: Raspberry Pi B+ turn usb power off
by watching the schematics of old modle A and B, the ubs powerline is hardwired directly without any possible control.
the schematic of the computer module shows, that the usb power seems to be not controled as well.
the full schematic of model A+ and B+ i can not find on the documents github at schematics section
what i see on my Modle B compared to my Modle B+, when i "sudo poweroff" it is, that connected usb devices on a Modle B stays powered on and at Modle B+ they turned off. so i think it is like "jdb" told, it is possible to control the power on a RPi Modle B+ (Modle A+).
section available for RPi Model B+ and A+ ?
(the partial schematics of Modle B+ is a kind of joke)
the schematic of the computer module shows, that the usb power seems to be not controled as well.
the full schematic of model A+ and B+ i can not find on the documents github at schematics section


what i see on my Modle B compared to my Modle B+, when i "sudo poweroff" it is, that connected usb devices on a Modle B stays powered on and at Modle B+ they turned off. so i think it is like "jdb" told, it is possible to control the power on a RPi Modle B+ (Modle A+).
PS.: does anybody know, why there is no full schematic on the github.com/raspberrypi/documentation/hardware/raspberrypi/schematicsjdb wrote:Yes it can...
section available for RPi Model B+ and A+ ?


(the partial schematics of Modle B+ is a kind of joke)
{ I only give negative feedback }
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)
Re: Raspberry Pi B+ turn usb power off
Because no one has had the time to generate the full schematics in a generally usable format yet.beta-tester wrote:PS.: does anybody know, why there is no full schematic on the github.com/raspberrypi/documentation/hardware/raspberrypi/schematics
section available for RPi Model B+ and A+ ?
-
- Posts: 71
- Joined: Tue Oct 30, 2012 10:44 am
Re: Raspberry Pi B+ turn usb power off
Thanks for the information! This will be usefull to reset my 3G modem if it stops respondingjdb wrote:Yes it can.mahjongg wrote:the PI (B+) has NO hardware in place to disconnect power to the USB ports!
it can detect a short, (USB power Fault) and then the USB power controller (P2553W6) will automatically block the USB power, but the PI cannot turn off the USB power using software. What it can do is bring the LAN9514 into sleep mode, but that does NOT turn the power off!
Issuing a USB Hub class request (CLEAR_FEATURE PORT_POWER) to port 2 on the LAN9514 will deactivate the USB output power switch.
There's an app for that:
https://github.com/codazoda/hub-ctrl.c

-
- Posts: 74
- Joined: Sat Aug 24, 2013 2:41 pm
Re: Raspberry Pi B+ turn usb power off
Won't
sudo udevadm trigger
not be easier to reset an errant 3G modem?
sudo udevadm trigger
not be easier to reset an errant 3G modem?
Setting up your Raspberry Pi to work with a 3G dongle http://nvdd.info/11gKrsZ
Re: Raspberry Pi B+ turn usb power off
I came across this thread yesterday and can confirm that hub-ctrl with '-h 0 -P 2 -p 0' will turn off ALL of the USB ports and by the looks of things the Ethernet port off too. If there's any finer granularity than all or nothing possible, please let me know. Thx
-
- Posts: 71
- Joined: Tue Oct 30, 2012 10:44 am
Re: Raspberry Pi B+ turn usb power off
For me this works 'hub-ctrl -h 0 -P 2 -p 0', it turns off only 1 port.
But you can turn off the Ethernet port with this command (if you another -P value).
But you can turn off the Ethernet port with this command (if you another -P value).
Re: Raspberry Pi B+ turn usb power off
Interesting, that looks to be the exact same thing that I did, but I'm certain that all of my USB ports went off (or at least 2 of them), plus the Ethernet would no longer work. I had to power cycle to get back in again.
Re: Raspberry Pi B+ turn usb power off
The Ethernet going off too does not surprise me at all, since it is actually a USB device being driven by the USB hub chip.cancunia wrote:I came across this thread yesterday and can confirm that hub-ctrl with '-h 0 -P 2 -p 0' will turn off ALL of the USB ports and by the looks of things the Ethernet port off too. If there's any finer granularity than all or nothing possible, please let me know. Thx
I was aware that the B ran the USB power directly from the 5v rail, but was not aware that this was changed in the B+. If it is controllable on a port-by-port basis, this could be very useful. In addition to the obvious abilities to shut off USB devices to save power, or to power cycle them, you could power certain 5v non-USB devices from a USB port and switch them on and off at will, essentially providing four outputs running at 5v. Potentially very handy! I'll definitely have to remember that.
Re: Raspberry Pi B+ turn usb power off
Why not use a mosfet to switch on/off the usb 5v? I think you could control the mosfet with a GPIO pin
-
- Posts: 71
- Joined: Tue Oct 30, 2012 10:44 am
Re: Raspberry Pi B+ turn usb power off
Yes that is how I did it on the Raspberry B but then you need to cut an USB cable for each device you want to control.
So if the mosfet is already there in the USB hub it is much easier to turn the device on/off with a command to the hub.
So if the mosfet is already there in the USB hub it is much easier to turn the device on/off with a command to the hub.
- mahjongg
- Forum Moderator
- Posts: 15100
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: Raspberry Pi B+ turn usb power off
the USB current monitor can be turned off by disabling the current monitor, the LAN9512 has its own I/O, and the signal PRTCTL2 (pin 14) that normally monitors an overload can be programmed as output, and then can turn of the current monitor, which cuts USB current.
Another thread in this forum taks about this in detail, including a piece of schematic.
Another thread in this forum taks about this in detail, including a piece of schematic.
Re: Raspberry Pi B+ turn usb power off
It is my understanding that on the B+ if you turn off the USB HUB you will turn Ethernet as well. You can not disable one or the other.
You can use the following commands to achieve this:
I have tried them by myself and unfortunately when I keep turning the USB HUB ON/OFF constantly, at some point the R-Pi hangs and I have to manually reboot it.
I'll try the hub-ctrl.c to see if it is more robust...
You can use the following commands to achieve this:
Code: Select all
echo 0 > /sys/devices/platform/bcm2708_usb/buspower;
echo 1 > /sys/devices/platform/bcm2708_usb/buspower;
I'll try the hub-ctrl.c to see if it is more robust...
Re: Raspberry Pi B+ turn usb power off
I tried hub-ctrl.c:
it worked for 24hrs without any problem.
Code: Select all
while (true) do hub-ctrl -h 0 -P 2 -p 0 ; sleep 3; hub-ctrl -h 0 -P 2 -p 1; sleep 57; done
Re: Raspberry Pi B+ turn usb power off
I tried hub-crtl.c with some success on a Pi 2 :
Reset ETH 0, and I lost my connection (have to reboot)
Reset all USB and ETH
Reset USB 4
Reset USB 2
Reset USB 3
I didn't find how to reset USB 1.
I want to reset USB connection on USB modem, I think I can do it with that tool but it doesn't work well at the moment.
Reset ETH 0, and I lost my connection (have to reboot)
Code: Select all
sudo ./hub-ctrl -h 0 -P 1 -p 0 ; sleep 3; sudo ./hub-ctrl -h 0 -P 1 -p 1
Code: Select all
sudo ./hub-ctrl -h 0 -P 2 -p 0 ; sleep 3; sudo ./hub-ctrl -h 0 -P 2 -p 1
Code: Select all
sudo ./hub-ctrl -h 0 -P 3 -p 0 ; sleep 3; sudo ./hub-ctrl -h 0 -P 3 -p 1
Code: Select all
sudo ./hub-ctrl -h 0 -P 4 -p 0 ; sleep 3; sudo ./hub-ctrl -h 0 -P 4 -p 1
Code: Select all
sudo ./hub-ctrl -h 0 -P 4 -p 0 ; sleep 3; sudo ./hub-ctrl -h 0 -P 4 -p 1
I want to reset USB connection on USB modem, I think I can do it with that tool but it doesn't work well at the moment.
Re: Raspberry Pi B+ turn usb power off
I know this is an old thread but I'm hoping an answer has been found for it. I'd like to attach an Arduino to my Model 2 Pi, but I don't want the Arduino to draw power from the USB port on the Pi (its default action). If the Arduino is supplied with 7+ volts on its RAW input, it will use that instead of USB power, but the power curve is terrible, the Arduino wastes a lot of energy.
It (the Ardiuono) has a 5V in, and will use either that or the USB port for power, whichever has the higher voltage. There's already a 5V rail in my circuit, but I can imagine the Pi flipping around if the voltages vary a bit between say 5.04V and 5.06V, for example.
So, is it OK to split open a USB cable and disconnect its power wire, then expect it to work properly ?
The reason for all of this is the Pi's USB power output isn't very strong, powering a USB WiFi dongle and 2 Arduinos won't work.
It (the Ardiuono) has a 5V in, and will use either that or the USB port for power, whichever has the higher voltage. There's already a 5V rail in my circuit, but I can imagine the Pi flipping around if the voltages vary a bit between say 5.04V and 5.06V, for example.
So, is it OK to split open a USB cable and disconnect its power wire, then expect it to work properly ?
The reason for all of this is the Pi's USB power output isn't very strong, powering a USB WiFi dongle and 2 Arduinos won't work.
Re: Raspberry Pi B+ turn usb power off
I don't know if this will help you or not, but your Pi2B (assuming that's what you mean by "model 2 Pi") can supply up to a total of 1.2A via its USB ports if you add...
...to your config.txt file. That's assuming that your Pi PSU can supply the extra current of course.
Code: Select all
max_usb_current=1
Pi4B 2GB Rev1.4 Mini-PC/Media Centre: ARM=2.25GHz @1.1v, Core=600MHz, GPU=850MHz. Raspberry Pi OS with KODI on 128GB Sandisk Extreme Pro A2 microSD card in Integral card reader in USB3.0 port (138MB/s read). Geekworm P173 case with copper shim on SOC.
Re: Raspberry Pi B+ turn usb power off
Thanks, I didn't realise that, it should be more than enough for my needs. Yep, it is a RPi2B.
-
- Posts: 1
- Joined: Tue Feb 23, 2016 8:38 am
Re: Raspberry Pi B+ turn usb power off
Hello,
I have a Raspberry Pi 2 B and I am experimenting witih hub-ctrl for power cycling the USB. For my applicatoin, I need to power on and off certain USB ports.
I found this code, contrary to what a previous poster said, power cylces all USB ports but NOT the ethernet. It successfully cuts the +5v power to all the USB.
This works as a crude method of cycling the power, except I would rather use per port switching if possible. If I switch the -P flag for hub-ctrl to "-P 4" or "-P 5" it works individually for USB ports 2 and 3 as desired, but it only cuts the DATA signal from the USB and not the +5v power, so the devices don't fully power on and off.
Does anyone know of a solution to cycle the +5v power on individual ports via software? Thanks for any help!
I have a Raspberry Pi 2 B and I am experimenting witih hub-ctrl for power cycling the USB. For my applicatoin, I need to power on and off certain USB ports.
I found this code, contrary to what a previous poster said, power cylces all USB ports but NOT the ethernet. It successfully cuts the +5v power to all the USB.
Code: Select all
sudo ./hub-ctrl -h 0 -P 2 -p 0 ; sleep 3; sudo ./hub-ctrl -h 0 -P 2 -p 1
Does anyone know of a solution to cycle the +5v power on individual ports via software? Thanks for any help!
-
- Posts: 12
- Joined: Mon Oct 12, 2015 5:16 pm
Re: Raspberry Pi B+ turn usb power off
Just tested this with the Pi 3 in case anyone is interested. Here is what I am seeing. The USB port numbering from the picture posted above:
Hub:Port -- Controlled port(s)
0:1 -- Controls the Ethernet port
0:2 -- Controls all four USB ports (not the Ethernet)
0:3 -- Controls USB Port 4
0:4 -- Controls USB Port 2
0:5 -- Controls USB Port 3
As best I can tell, USB Port 1 cannot be controlled individually. I was expecting 0:2 to map to USB Port 1, but it is being used to control all of the USB ports.
Hub:Port -- Controlled port(s)
0:1 -- Controls the Ethernet port
0:2 -- Controls all four USB ports (not the Ethernet)
0:3 -- Controls USB Port 4
0:4 -- Controls USB Port 2
0:5 -- Controls USB Port 3
As best I can tell, USB Port 1 cannot be controlled individually. I was expecting 0:2 to map to USB Port 1, but it is being used to control all of the USB ports.
- DougieLawson
- Posts: 42772
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: Raspberry Pi B+ turn usb power off
You get a better picture by running a lsusb -t (ell, ess, you, ess, bee, space, minus, tee) command.
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.