Recently I set up a Raspberry Model A+ with a Python script to log temperature to the internet. I used an Edimax EW-7811 WiFi dongle to connect to it using SSH. This worked fine but occassionally I would lose the connection for no apparent reason.
After a bit of Googling it appeared that a power saving mode might be responsible. It seems the dongle turns off if no one is typing at a keyboard. Even if the dongle is constantly transferring data via WiFi it just gives up. Not sure why the hardware would be programmed to do that because it’s completely insane. I’m all for power saving but I like WiFi to stay up when I’m actually transferring data over it!
Luckily there is a solution. It involves disabling the power management so the dongle stays connected. The following technique should work for all WiFi dongles that use the Realtek RTL8192 chipset.
Disable Power Management
First you read the power management flag using :
This will report a value of “1”.
To set it to zero you can use :
sudo nano /etc/modprobe.d/8192cu.conf
and add the following line :
options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
To quit from nano use [CTRL-X], [Y] then [ENTER].
You are now ready to reboot using :
The two options we set in the configuration are rtw_power_mgnt and rtw_enusbss. If you are interested they take the values defined below :
- 0 = disable power saving
- 1 = power saving on, minPS
- 2 = power saving on, maxPS
- 0 = disable auto suspend
- 1 = enable auto suspend
So setting them both to zero disables “power saving” and “auto suspend”.
Here are a couple of sites I used on my quest :