aoakley.com

Raspberry Pi Power and WiFi

You know how seemingly ten times out of ten, a problem with a Raspberry Pi is down to poor power supply? SD card errors, strange boot failures, network dropping out? Typically this is due to either:

I've been working my way through mains adapters and have finally found a selection that seem guaranteed to work with everything, and which are widely available. There is, however, a common problem with USB nano WiFi / wireless network adapters which is not to do with power supply, but to do with power saving - we'll come to that in a moment.

Best Single-Socket Micro USB Mains Adaptor for the Raspberry Pi

Far and away the best single-socket mains adaptor for the Raspberry Pi is the Nokia AC-10. I think it's the best because:

The model number for UK mains sockets is the AC-10X; for European sockets it is AC-10E; for North America it is AC-10U. However all of these models are mains multi-voltage and will accept 100-240V at 50-60Hz. So you can take it abroad and use it with mains travel adaptors. Annoyingly, it is discontinued - but there is enough stock around the world to keep Raspberry Pi owners happy for the next couple of years at least. Its replacement model, the AC-60, is even higher ampage at 1.5 amps, but is currently much more expensive, and doesn't come with a cable.

There are plenty of other suitable adaptors - the 1000mA one supplied by default by Farnell and the 1200mA one supplied by RS Components are both good - but in the aftermarket range, I think the Nokia AC-10X provides the best balance of availability, price, reliability and ampage.

Best Multi-Socket Micro USB Mains Adaptor for the Raspberry Pi

For multiple USB power outputs, the most reliable I've found are the no-name 4-port travel USB adaptors with interchangable international heads. These are best because:

These are manufactured under a variety of names, including Bestek, Dot.Foto, Artic Cooling, Kensington and most often described as "Universal". They are typically supplied with between one and four international mains plug heads, which clip into place over the Figure-8 socket and require a release button to be depressed to unclip them. Some have the USB sockets on the base (pointing down), others on the back (pointing perpendicular to the wall).

Power problems with USB wireless nano WiFi adaptors

Even after buying a powerful and reliable power supply, USB nano WiFi adaptors often fail to perform. They'll work fine on boot, but as soon as the network traffic dies down, they become unreliable.

The problem here is that many of these nano adaptors use a power-saving mode designed for smartphones and tablets where the network traffic is typically predominantly outbound. If the Raspberry Pi doesn't send any network traffic for a while, the nano wireless adaptors go into low power mode and become difficult to contact from an external source. For example, you may not be able to ping or establish an SSH connection from your desktop PC to your Raspberry Pi, or an SSH session may become unreliable after being left idle for a few minutes.

These power-saving modes can, and I believe on a Raspberry Pi always should, be turned off. The actual power saving is pretty minimal, especially if you actually want to have the Pi serving data pretty much constantly. Even when powering the Raspberry Pi from a battery (such as one of those mobile phone emergency power packs), I have found it far better to turn off the WiFi power saving. There's not a lot of point in my Raspberry Pi robot having a little extra battery life, if it spends three quarters of that time being uncontactable.

One of the most popular chipsets for USB nano wifi adaptors that are compatible with the Raspberry Pi is the Realtek RTL 8192CUS . You can find out which chipset you have by doing:

lsusb

...which will display something like:

Bus 001 Device 002: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

You can turn off power saving by issuing the command:

sudo echo -e "\n# Disable power management\noptions 8192cu rtw_power_mgnt=0" >>/etc/modprobe.d/8192cu.conf

What this does is add the instruction options 8192cu rtw_power_mgnt=0 to the file /etc/modprobe.d/8192cu.conf , plus a little comment reminding everyone what it's for; you could edit or create the file yourself in nano or vi if you prefer.

Rebooting the Pi ( sudo shutdown -r now ) is a simple and effective way to bring the setting into effect. The setting will be remembered upon subsequent reboots. You can undo this setting by commenting out the options line in 8192cu.conf or, if you don't have any other settings you care about, deleting the file ( sudo rm /etc/modprobe.d/8192cu.conf ).

And yes, this works for the 8192CUS chipset even though the file is named 8192CU (missing an S). Unsurprisingly it also works on those very rare 8192CU chipset devices too. The setting also works for the 8188EU chipset, although you will have to change mentions of 8192cu to 8188eu , thus:

sudo echo -e "\n# Disable power management\noptions 8188eu rtw_power_mgnt=0" >>/etc/modprobe.d/8188eu.conf

Solving the power cable length problem - AC or batteries

Okay, so right at the start of this article, we talked about how a USB cable could be five metres long and still good for data, but not for power.

My recommended solution is to bring your AC as close as possible to your Pi. You can do this either with a standard mains extension cable, or you can use a DC adaptor which has an AC socket, such as the 4-port USB travel adaptors with Figure-8 mains sockets I recommended above, which allow you to use potentially very long Figure-8 mains cables, the kind you might use with a kitchen radio or a hi-fi separates system.

Failing that, get a good reliable mains adaptor that puts out at least 1000 milliamps (1 amp) and is slightly over the 5 volt output. The USB specification, and the Raspberry Pi specification, allows for up to 5.25 volts maximum and 4.75V minimum. The Nokia AC-10 I recommended above, gives out around 5.05-5.2v, so you can lose 0.3v and still be okay.

I tried a number of different cables and found that a non-overclocked Raspberry Pi model B revision 2 performs acceptably with the Nokia AC-10x cable length of 1.8 metres plus a Micro USB extension cable of 1.2 metres. However with a less powerful/reliable power supply, 2 metres total cable length worked whereas 3 metres didn't (problems reading the SD card).

So ideally you should keep your total USB DC power cable length to 2 metres or less, and if you must use a USB cable extension lead, you will almost always have problems above 3 metres total length, even with an ideal power supply. It is much, must better to extend your AC leads rather than your DC/USB leads.

Of course, there is one final near-perfect solution to the cable length issue; use batteries. Most of the beefier mobile phone emergency chargers will do the job, provided they can provide enough amps. The cheaper mobile chargers will only supply 500mA.

The Model A Raspberry Pi really does represent a significant power saving. Model B at idle with nothing attached uses 375mA; doing some number crunching it ups to 450mA. A nano USB WiFi dongle adds 100-200mA depending how far it is from the router. The official Pi camera adds at least 200mA. The Model A idles around 115mA and crunches numbers up around 160mA.

Equipment Current, approx.
Model B 450mA
Model B with WiFi, close range 550mA
Model B with WiFi and camera 750mA
Model A 160mA
Model A with WiFi, close range 260mA
Model A with WiFi and camera 460mA

Figures very approximate. Add at least 100mA if you are in a weak WiFi signal area or doing heavy processing. Add another 100mA if you are connecting a mouse, keyboard and display.

Public Domain - Andrew Oakley - 2014-02-25

Top - More Computing Articles - More  Reviews Articles - Article Index - aoakley.com