When I first powered up my Raspberry Pi, I was using a 1A charger from an HTC Desire phone. This ought to provide enough current to power a USB mouse and keyboard, plugged into each of the Pi's USB ports. However, I was suffering from random key repeats and missed keypresses. Besides, I wanted to connect a USB wifi adaptor too, and there was no way this was going to work with an unpowered USB hub: the Pi can only supply a total of 140mA.
Being a cheapskate, I baulked at the idea of spending almost as much again as I'd paid for the Pi itself to buy a powered USB hub; besides, I already had a meaty 4A mains adaptor from an old label printer. What's more, a powered USB hub would require a separate mains adaptor, and it would be much neater to power everything, Pi and peripherals, from one plug.
The solution: buy a cheap unpowered USB hub from a pound shop and butcher it about a bit with a soldering iron and a craft knife. Here is what I came up with (click to make bigger):
As you can see from the picture, there are two protruding leads: the silvery one is the original lead from the hub to the computer's USB port; the black one, terminated in a micro USB plug, is the one I have added which goes to the Pi's power socket. You can also make out the power socket I have added for the input power from the PSU I'm going to be using. It's clearer in this picture:
If you want to make one of these yourself, it's pretty simple. You will need an existing power supply that can deliver 5V and enough current to power your Pi plus whatever else you want to plug into the hub. I would recommend at least 1.5A. (Current is given in amps (A) or milliamps (mA) on your charger or power adaptor, 1.5A being the same as 1500mA.) Bear in mind that some power supplies will drop the voltage as they deliver a higher current, so a supply that looks on paper as if it ought to be borderline good enough might still not work. Some people have reported getting Pis to work with supplies rated at 6V, but I'm guessing the voltage maybe fell when loaded. The label printer PSU which I am now using delivers 5.15V unloaded. If you stay below 5.25V, you should be OK. Your mileage may vary, as they say.
You will also need a socket that pairs with the existing plug on the power supply you're going to use. (That's the part sticking through the clumsy cut-out in the plastic casing in the photo above.) If you don't have one, you could simply chop off the plug and wire the power supply directly into the hub, so it has three leads permanently going into it. This strikes me as getting a little ungainly; besides, it means you won't be able to use the power supply for anything else in the future. Up to you. If you do do this, obviously you need to adapt the instructions below where it talks about fitting the power supply socket: just solder your two wires from the PSU direct to the board instead.
Finally, you need to live near one of those ubiquitous and wonderful pound shops that sell HDMI leads, toothpaste and 72-packs of no-name batteries for a pound a punt. Most of them have a small computing/AV/electrical section and if you're lucky it will supply you not only with a nice little unpowered USB hub like the one pictured, but also an encapsulated micro USB plug (the black lead in the photo). Mine was sold as a USB Blackberry charger. Chop off the full-size USB plug from the one end and you're left with a Raspberry Pi power lead. Total cost to you: two quid.
If you prise open the two halves of the clamshell that comprise the hub (which it is mercifully possible to do without breaking it permanently) you'll find the silvery USB lead (yours may not be silvery; the hub itself may be blue or pink; use a bit of imagination here) has four inner wires soldered on to the board. The red and black ones are the positive and negative power supply. The green and white ones are the data lines. (At least, this was the colour-coding for the hub I bought.) The essence of what we're going to do is divert the power wires to our replacement external supply, but leave the data ones where they are. This means your USB peripherals will draw their power directly from the PSU, not from the Pi; while the data lines will still go to the Pi's USB socket. Here is a photo of the underside of the board:
As you can see, I've simply snipped the red and black wires from the USB lead, leaving only the green and white data lines connected. Next, I found a convenient place on the edge of the board to mount the input jack for my PSU plug. (It's not really mounted; it kind of hangs over the edge and is held in place by the fat wires and goodwill.) I chose that specific corner for it because, for some reason, there was already a round hole cut out of that corner in the moulded plastic, previously unused, and easily big enough to poke a cable through. I felt it was meant to be when I first noticed this.
You need to connect the input jack to the positive and negative power tracks on the PCB from where you've just snipped off the existing power supply from the USB lead. My replacement PSU has a coaxial plug which supplies negative to the centre pin and positive to the barrel of the plug, so I have connected a red wire to the foremost tag and a black wire to the rear tag on the power socket. Then I soldered the other end of the red wire to the PCB where the red wire from the USB lead was previously connected, and the black wire to the PCB where the black wire from the USB lead was previously connected. In fact you'll notice I haven't done exactly that: I've traced the tracks on the PCB to find a more convenient place to solder them on; this is fine and makes more room in the rather cramped plastic housing. The two ends of the four terminals where each USB socket is mounted are always the power supply (and the two middle ones always data). Just make sure you get them the right way round.
So now we have a powered USB hub, but no power yet for the Pi itself. To remedy this, solder the lead from your chopped-off pound-shop encapsulated micro USB lead on to the board as I've done. Again, you can use any convenient terminals which you identify as being electrically connected to the positive and negative supply. In this case you can see I've actually soldered them to the exact spot (but on the other side of the board) where I snipped off the original power leads. Slightly confusingly, this time I found the power lines were colour-coded red and white (not black). I'm afraid you'll have to work with what you find.
Finally, I blobbed some glue liberally on top of where I'd soldered, to mitigate the effects of jiggling the wires round (since there's no room for proper strain relief) and snapping them off over time. That would be it, except that with the addition of the coaxial socket for the power input, the case now won't snap back together. This is where the craft knife comes in. My best effort looked like this:
You can probably do better.
Before you carefully feed the wires through the holes and snap the whole lot back together, I would strongly advise you to get your multimeter or continuity tester and check you have not inadvertently made a short circuit between the positive and negative supply terminals. In fact there should be no continuity between any of the four USB terminals. A minor precaution against frying your Pi and blowing up your PSU when you plug it in. (Though I emphasize that your carrying out any of the above, and the consequences you may realize by doing so, are entirely your own responsibility, not mine. I might have made a mistake in my instructions. You might make a mistake carrying them out. Weigh up the risk yourself and be judge of your own competence. If it doesn't work, or causes actual damage, it's your responsibility!)
If you've gone ahead, done all that and shouldered the responsibility as requested, you're ready to go. Insert the USB plug (on the silvery lead in my case) into one of the Pi's USB sockets, and insert the micro USB plug (black in my case) into the Pi's micro USB power socket. Finally, insert the plug from your power supply into the socket you've added to the hub. Everything should spring into life (assuming you remembered to connect the display and insert the SD card). You now have five USB ports to play with: one left on the Pi itself (which should supply 140mA; call it 100mA for safety) and four on your new powered hub, which should be good for however high the rating on your PSU is (minus whatever the Pi itself is drawing). And the whole lot runs off a single mains plug.
Thank you. I *knew* there had to be a more elegant solution for using several USB peripherals with the Pi than two separate power leads. Now I can easily mount the usb hub inside my casing next to the Pi and just have the power lead trailing out.
ReplyDeleteNicely illustrated - even I can see where I need to be soldering ;)
Nice mod and one I am in the process of doing myself (although my £1 hubs are electric blue ha ha). One tip for anyone else doing this, if you don't want to cut the case up, you can make a cheap flying power socket using a PCB one (salvaged in my case) and some heat-shrink sleeve.
ReplyDeleteThanks. This was exactly what I was looking for. It would be help full if you showed or linked to pin out diagrams for the USB connections.
ReplyDeleteThanks for the comments. My local Poundland now has bright pink hubs in (otherwise the same as the black one pictured) which I think would look rather fetching. Glenn's tip sounds good; I considered it myself but didn't have any shrink wrap, only black electrician's tape, and I thought that would be messier. USB pin-outs are on Wikipedia at http://en.wikipedia.org/wiki/Usb
ReplyDeleteMy version, less butchery :)
ReplyDeletehttp://rgwni.blogspot.co.uk/2012/08/powered-usb-hub-2.html
so... basically you just cut the power cables(red and black) from the original usb cable and added your own power to one of the usb ports and that will power all the ports? am i right? 2A power supply is to much?
ReplyDeleteYes, although the growing consensus seems to be that you leave the original ground connected (black) and just cut the positive power line (red). You still connect both red and black from your new supply, though. The power rails are all connected together on the PCB, so will power all the ports. 2A sounds fine, and not too much, unless you're using very thin cable (not recommended). Take a look at Glenn's site: it's good, it's got further explanation.
ReplyDeleteHello. Let's say we have the original not modified usb hub. What happens if I connect the original data/power plug to a USB AC wall adapter to power the hub and then I use a male to male usb cable from one hub usb port to one Raspy usb port? Is there some kind of risk? Is there a power limit that the original usb cable could support? Thanks for attention.
ReplyDeleteIf I'm understanding you correctly, I don't think this would work. You'd have the input data pins to the hub unconnected, as they're going into the power supply. The four ports on the hub itself can't be used as input to the hub. Plus you'd still need a separate power supply for the Pi (it can't be powered by an input voltage on either of its two USB sockets) and then you'd also have two 5V outputs meeting each other if you connect the two devices with a male-male USB cable as you suggest. Sounds like a bad idea to me.
ReplyDeleteYou understood me correctly. Thanks for clear answer.
DeleteFollowing instructions bought this:
ReplyDeletehttp://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=310263758524
I know its 46p more but fuel to the nearest poundland ? !!
Easy to open - no glue or clips and to my surprise its already got a power socket and hole is case, just need to find the right size plug to make an adaptor for my existing power supply with no soldering !
Will solder in a power out for the mini usb in later.
Hello Alan
ReplyDeleteIn some places i saw that someone is not cutting the Black Wire that comes from the USB Hub going to the RPI USB Port, this because they are telling something about a common negative point that has to be shared from the RPI and the 5V and USB.
I am not an expert, may this be real or is your mod better because cutting out the Black wire too?
Thank you
I'm not an expert either. Other people have also told me it would be better to leave the black line connected (see my reply to Carlos above). All I can say is that I built mine as described, with both lines cut, and haven't had any problems.
DeleteHello Alan
DeleteThank you very much for your answer. I ordered 2 RPI's from Germany, a friend of mine and a cousin was so good to provide them. I live in Brasil where ii is possible order the RPI but the price here is too high, i am speaking about 170 Reais + Packaging that will be 230 Reais for me (about 90 Euro). Really too much considering the cost in Europe of the small wonder. So i am hopefully waiting for the packages arriving here and put the systemrunning up.
I'll contiunue watching your blog here for any news.
A i forgot something. Can you give me the output of your command -lsusb- to see the usb vendor of the Hub please.
ReplyDeleteThis is crazy but I can't seem to get the 'hub' ports to work. I have power going through it but can't connect my keyboard or mouse to it.
ReplyDeleteHere's an image:
http://imageshack.us/photo/my-images/197/img07081.jpg/
The red shrink tube is to the micro USB which works. The green, white, and black are going to the a USB port on the Pi. Last the original silvery white cable, goes to the power/wall wart. For the power cable I kept all the lines connected. Was this wrong? Should I only have three? I didn't think it mattered. Any suggestions? Thank you.
I figured it out. Everything is wired correctly but the chipset is the GL850G chipset, which doesn't register with the Pi, nor Windows come to think of it.
DeleteSo for those of you out there looking to do this, make sure you check the wiki below to make sure your hub will work.
http://elinux.org/RPi_VerifiedPeripherals#Problem_USB_Hubs
Are you sure, Xinerama? Maybe I'm misunderstanding you, but it would seem a bit dumb to me for any manufacturer to make a USB hub chip that won't work with Windows. If that's a PCB from a cheap unpowered USB hub (which it looks like) then it must work with Windows, surely! (Though I'm more willing to believe it won't work with the Pi, if you say so.)
DeleteI'm not convinced you're wired up properly. Is that thick pink lead the Pi power input? If so, why three connections? You should just have two power connections from the mains adaptor, two power connections to the Pi micro USB, and two data lines to the Pi full-size USB (if you're building it 'original flavour' as described in the blog post).
Sorry, Vincenzo, haven't had time to have the Pi on for ages so I still haven't run lsusb for you. Maybe one of the others who've had success could post theirs on here for you? Cheers.
For the lazy:
ReplyDeletehttps://www.modmypi.com/shop/raspberry-pi-accessories/New-Link-4-Port-USB-Hub-(USB-2.0-with-Mains-Adaptor)
I was interested in trying this, so bought a couple of poundland hubs today to experiment with. Of the ones I purchased none of them are actually USB2.0, so any data transfer would be very slow.
ReplyDeleteThey say USB 2 on the packaging and are identified with the name "USB 2 HUB" or similar when installing. But they do not support high transfer speeds as windows complains if I put a USB2 pen drive in them (the device could run faster …).
The hub I have looks like the one in this post but the PCB is different, so maybe there are some USB2 versions out there, but just wanted to warn people that they may find they get poor performance due to USB1 speeds. That said if you just wanted it for a keyboard and mouse USB1 would be fine.
On a completely different note, anyone considering doing this using the poundland ‘slim’ USB hub (also really USB1), may want to check out the following worrying posting on the Raspberry Pi forums: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=27890&p=267890
Thanks, Alastair. That's an extremely interesting couple of comments, and rather worrying, as you say. My Poundland hub definitely doesn't install any hidden keyboards and it does seem to be a genuine USB 2.0 chip. Vincenzo asked me back in October to post lsusb and I never did, so here it is now in its verbose form (sorry about the formatting; Blogger won't accept code tags):
DeleteBus 007 Device 002: ID 05e3:0606 Genesys Logic, Inc. USB 2.0 Hub / D-Link DUB-H4 USB 2.0 Hub
Couldn't open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 9 Hub
bDeviceSubClass 0 Unused
bDeviceProtocol 0 Full speed (or root) hub
bMaxPacketSize0 8
idVendor 0x05e3 Genesys Logic, Inc.
idProduct 0x0606 USB 2.0 Hub / D-Link DUB-H4 USB 2.0 Hub
bcdDevice 7.02
iManufacturer 1
iProduct 2
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 25
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xe0
Self Powered
Remote Wakeup
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 9 Hub
bInterfaceSubClass 0 Unused
bInterfaceProtocol 0 Full speed (or root) hub
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0001 1x 1 bytes
bInterval 255
Thanks for the post! I made the exact connections you did and everything went well!
ReplyDeleteBtw, I used a PSP charger and here are the voltages for those who are also looking at using this:
Unloaded - 5.91
Loaded (login screen) - 5.41
Couldn't edit my comment. Correction on the voltage readings..
DeletePSP charger
Unloaded - 5.41
Loaded (login screen) - 4.91
Also -
iPad charger (one that came with the 3rd gen which is rated 10W)
Loaded (login screen) - 4.60
Specific items mentioned here may not be available where you are located. You will want at least a 1000ma supply but be advised that not all USB wall supplies output within the acceptable range. Fortunately, most of them are close enough that the Pi input circuitry will clamp it to 5 volts. The polyfuse is supposed to open if the voltage exceeds 6 volts and there is a 5 volt zener diode that is supposed to limit the voltage. Some 7-port hubs do not work properly even if their 4-port version does (check the link above). Try to get a powered hub to offload some of the current requirements of the Pi. I found my power adapter at a thrift store and my 4-port hub is by Gear Head. Got it at a Walmart store but then I live in the states. thanks!
ReplyDelete----------------
the power adapter supplier
Your article inspired me to do something similar, but I ended up going the route of back-powering my Raspberry Pi via the USB port, instead of ataching a separate micro-usb cable. See http://thestuffsido.blogspot.com/2013/05/powered-usb-hub-for-my-raspberry-pi.html
ReplyDeleteI am curious, won't your solution also end up back-powering your Raspberry Pi through the normal "data" USB port, since the circuitry of these USB hubs are so simple and, in my case, supplied all USB ports with any current required/available.
The data USB port in my project only has the two comms lines connected; the two power lines are cut. The micro USB port is the opposite: only the two power lines are connected, and not the comms lines. If connecting all four lines on the data USB port, and not bothering with the micro USB connector at all, works, then I'd agree that that's a more elegant solution. Is this what you have done? I'm afraid I can't open your link -- it's just a blank white page in my browser (other blogger sites work fine for me, so I'm not sure what the problem is). If that is what you mean, I didn't consider doing that as it didn't occur to me it would work: I thought the power had to come through the micro USB.
DeleteAwesome idea, I have an identical USB Hub, managed to connect the DC Female barrel connector, working fine, but in the process (my HUB was quite old and the wires were dusty and brittle) I accidentally broke off the white and green data lines, so i took them off and soldered them to their respective pins on the other side of the PCB, (these are the lines coming from the main USB Male header to the board btw), but here's the thing, power works fine, but right now while testing it with my laptop, the devices aren't getting recognised, any ideas? where can I email pix etc if you require them?
ReplyDeleteI can't work out from your description exactly what you mean, unfortunately. If you upload an image (e.g. to Flickr, photobucket, etc.) I might be able to see what's up.
DeleteWorked flawlessly for me. You don't really need the third (cut) micro usb cable to power the rpi. you can power it directly by using a normal micro usb cable plugged into one of the hub ports. (you lose one usb port with that which wasn't a problem for me)
ReplyDeleteYes, it comes to the same thing. But your way makes the project even easier to do, and saves chopping a perfectly decent USB cable in half, so thanks for pointing it out!
DeleteThis does not work for me on Raspberry Pi Zero W.
ReplyDeleteI have a 10A power supply and it is not down to power consumption... I guess.
Maybe when I get a Pi B+ model it will work... :)