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 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.
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.
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.
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.
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.
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.
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 http://ftp.de.debian.org/debian/pool/non-free/f/firmware-nonfree/firmware-ralink_0.36_all.deb
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 http://mirrordirector.raspbian.org/raspbian/pool/main/w/wicd/wicd_184.108.40.206-2_all.deb
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.