Adding wi-fi to a Raspberry Pi without a powered hub

It is a commonly known problem that the Raspberry Pi cannot provide enough power for most USB wi-fi adapters. This can be solved with the use of a powered hub, however I have plans to integrate the Raspberry Pi into other devices; due to space constraints I decided that it would be better to convert a dongle to draw power separately to its data connection, also taking the opportunity to reduce the distance that it projects past the end of the board.
The modified dongle plugged into the top USB port of a Raspberry pi

The starting point was a cheap dongle I bought from ebay for a couple of quid; luckily enough it’s based around the Ralink RT5370 chip, this makes it fairly straightforward to obtain drivers suitable for the Raspberry Pi. The first step was to take it to bits and see what I had to work with; this was achieved by bending a couple of tabs on the connector and slipping it off, after which the case pulled apart. No surprises here- a board with USB connection pads on one end, circuitry in the middle and an arial on the other end.
The two case sections and the circuit board that comprise the dongle

I needed a plug to fit into the USB socket, but wanted to keep the protruding length to a minimum. Luckily 0.1″ strip board has ideally spaced conductive strips and an appropriate thickness; I cut a small piece and pushed it tightly into the shield. I then soldered on 3 lengths of fairly stiff wire, one for ground and two for data. I also soldered on wires for the ground and power, I was having a stupid 5 minutes at this point- only the ground wire is required, attaching the 5V connector here is exactly the opposite of what I was trying to do.
A very short USB plug made from a piece of stripboard with wires soldered on.

Before attaching the dongle board, I decided to improve the arial in the same was as I did to a bluetooth dongle. Wi-fi uses a very similar frequency band to Bluetooth, so 31mm is still the corect length.
The circuit board from the dongle with a length of jumper wire forming a replacement aerial

To attach my new plug to the board I bent the pins over, trimmed them to the correct length and soldered them to the pads which would normally make contact in the USB socket. It was at this point I noticed my previous stupidity and moved the +5V wire from the strip board onto the dongle board.
The dongle board with the strip board plug freshly soldered, sticking out at an angle to give room for soldering

To provide a little more support and some protection, I refitted the case; this did involve a little trimming so that the board would fit in upside down and for the aerial, but otherwise was a good fit. Once there was no need to access the board I bent the leads more so that it laid flat.
The dongle, plug and wires attached with the case reattached

Now that I had attached separate power wires, I needed to connect the other ends to a 5V power supply; a 1A USB power supply should be able to provide enough power to run both the wi-fi dongle and the Raspberry Pi. Again for size reasons, I bought a US mains adapter (the size of a UK 13A plug imposes quite a large lower size limit otherwise). After cracking the case open, it was very simple to find somewhere on the board to attach extra power connections. I cut a couple of notches either side of the socket for the wires and reassembled it, this allowed a USB lead for the Raspberry Pi to fit in addition to the new wi-fi power wires.
A mains-USB adapter with wires leaving notches either side of the USB socket

Now that the hardware was sorted, there was the driver issue to contend with; the standard Raspbian image doesn’t include any drivers for this chip. There was the compounding problem of not having easy access to a wired connection to be solved. I put the SD card into my computer and downloaded the debian driver package to /home/pi using wget:

/media/29b6c2f4-5469-49f2-abd5-daa9149021cc/home/pi$ wget

Once the package had downloaded onto the card, I booted the Raspberry pi; installing it was as simple as:

~$ sudo dpkg -i firmware-ralink_0.36_all.deb

At this stage I was able to use ifconfig to confirm that a new wlan0 network interface was recognised, however it still required configuration. I tried several conf file approaches without success, in the end finding that the easiest way to enter the appropriate settings was by using wicd. Those of you that are on the ball will have realised that I was still without a working internet connection, apt-get was clearly going to need some help. I used the –print-uris option to get a list of the files that needed to be downloaded and save them to a file:

$apt-get --print-uris install wicd > wicduris.txt

I then put the card back into my other machine; I navigated to the home directory and opened wicduris.txt to find a list of .deb files to download. Now the trick I used here relies on the fact that whenever apt-get downloads a package it stores a copy in its cache for later use; I subverted this behaviour by manually downloading the required packages directly into its cache such that it would find them and install from these packages automatically. I changed directory to /var/cache/apt/archive and used wget to download each package one by one, for example:

/media/29b6c2f4-5469-49f2-abd5-daa9149021cc/var/cache/apt/archive$ wget

Swapping the card back into the Raspberry Pi allowed me to to boot it and install wicd in the usual manner without worrying about the lack of connectivity:

$ sudo apt-get install wicd

For some unknown reason, the command line interface to wicd was unable to detect any networks; I worked around this easily enough by starting an X session and using the graphical interface. I was pleasantly surprised to not even have to search the menus- a wpa_gui icon was sitting conveniently on the desktop. I entered all the parameters into the boxes and it connected successfully; these settings persist after reboot, even without having to start an X session.

11 thoughts on “Adding wi-fi to a Raspberry Pi without a powered hub

  1. Pingback: Injecting power into a WiFi dongle for the Raspberry Pi

  2. Pingback: เพิ่มกำลังไฟให้ USB Wi-Fi Dongle ด้วยการต่อสายตรงเลย | Raspberry Pi Thailand

  3. Sergio

    Thanks for your tutorial.

    However, don’t you get reverse current throught the usb to the Raspbery Pi?

    Is the Rpi fuse enough to stop it?

    Thank you.

  4. Travis

    Sergio, he won’t get reverse current because the +5v only goes to the dongle. He only soldered the D+ D- GND to the extension

  5. Scott

    The only thing I would be afraid of is that you’re forming a ground loop by having both the USB and Raspberry Pi connect to ground separately. Obviously that didn’t cause much of a problem here, but it’s just something that sets my teeth on edge. Either way, cool hack, and the final device looks pretty good!

  6. Pingback: Adding wi-fi to a Raspberry Pi without a powered hub #piday #raspberrypi @Raspberry_Pi « adafruit industries blog

  7. poglad2011

    This is all well and good, but for many Pi owners it would be far simpler to buy an Edimax EW-7811Un nano wireless dongle. In the UK, Amazon sells them for £9 ($14). It performs superbly without a powered hub, and the driver is now included in the official Raspbian distro (probably in Adafruit’s Occidentalis as well, for all I know), so it just works “out of the box”. It may be “commonly known” that the Pi cannot power a USB wifi adapter without a hub, but the EW-7811Un works fine on all of my Pis, including the original version I got in July.

  8. Mike Post author

    This is a very good point; I originally connected both the +5V and the ground to allow the Rpi to be connected to a different power supply. If it is being powered from the same supply it would be prudent to disconnect the ground wire.


Leave a Reply