Jun 14, 2013

Raspberry Pi with RT5370 Wireless Adapter

My PI worked flawlessly for some time hooked up to ethernet, but I wanted to move it away from router, and for this I bought some noname wifi dongle. After hooking it up, I run lsusb and it showed up as:
ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
Google told me that it should work out of the box. I used vanilla configuration:

/etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
        wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

/etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
update_config=1
network={
        ssid="MYSSID"
        scan_ssid=1
        mode=0
        proto=WPA2
        auth_alg=OPEN
        pairwise=CCMP
        group=CCMP
        key_mgmt=WPA-PSK
        psk="MYPASSWORD"
}
The system behaved weirdly, it worked for some time with very sluggish connection speed, but most of the times, ssh connections where just timing out. People complaining about unstable performance, where told to hook it through powered USB hub, since it is possible that power supply on Raspberry cannot produce enough power.



I have Raspberry model B (with 512M), so my malfunction was not a problem with model A, having 140 mA fuses on USB ports. Logical conclusion was, that power supply I got from Amazon (5V 850 mA) wasn't enough.
Endless scanning of Amazon/Ebay for USB power adapter with current over 1A, showed that most of the items sold are a horribly designed devices with characteristics  far from declared. With this in mind, I finally bought on eBay power supply marked as "5V DC 2A High Quality regulated power supply adapter".
I didn't really expect to get 2A out of it, I hoped that at least it will provide a little more than 1A.
In my test with dummy load supply maxed at 1.7 A, producing 3.6 V, but was happily producing 5.06 V at 1.2 A. Awesome ! The supply did have round plug instead of USB, but I had a spare USB socket and made a dumb converter:


Hooked the new power supply to the PI, and WiFi still didn't work properly. Same problems with timing out connections and slow console response. Since I used a converter with open wires, I could measure the voltage:

Voltage was very reasonable:
This ugly wave is a voltage ripple of power supply, but it's only 140 mV, without any sudden drops, and average is slightly above 5.25 V spec. Let's test the old power supply.
I didn't have breakout wires on the old power supply, so I measured voltage on LDO regulator:


Voltage is 5.03-4.91 (in spec), no problem with old power supply as well!

After all this madness with power supplies, both supplies are fine, but WiFi still doesn't work. Back to software. SSH connection from another computer doesn't time out, when PI is pinging other host. Looks like network operations at PI keep the WiFi adapter responsive... Weird. Power saving feature of the WiFi adapter? YES! 
Changing the /etc/network/interfaces
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
        wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
        wireless-power off

iface default inet dhcp
 No more timeouts! After reading the power save specs, it looks like this WiFi dongle does not support it properly, so it needs to be disabled. The drawback is adapter constant heating and waste of power.

5 comments:

Anonymous said...

good man, thank you for the tip

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

bulls eye!
Running like an headless chicken for two days trying to fix the same problem. Instant fix!
Thank you for the magic tip.

Anonymous said...

Thank for the powersave off tip!
However, most of powersave issues are located at the wireless router, not at client devices, so when you disable powersave on your device, you kind of workaround the bug at the router 8-)
Can you tell us what is the wireless router you used?
Also nice posting of the voltage output from your power supply.

Z273

Unknown said...

My router is pretty common netgear wnr2000v3.
It doesn't have any power-saving settings in it's UI, and all my other devices (laptops,cellphones,tablets) work with this router without any problems.