rooster
Posts: 100
Joined: Thu Aug 02, 2012 8:09 pm

intermittent wifi

Thu Oct 04, 2012 10:14 am

I have an outside PI application connected via wifi to my home network but it can be quite intermittent. If I lose the connection I seem to need to reboot the PI to get it back again. Is there a way to automatically regain the network connection or should I just do

while [1]
ifup wlan0
wait 10
endwhile

?

Wolfram23
Posts: 73
Joined: Thu Jul 19, 2012 6:50 pm

Re: intermittent wifi

Sun Oct 21, 2012 5:05 am

Looking for an answer on this as well. I'm trying to SSH onto my new Pi with PuTTY. I've got it set up and working, but after a certain amount of time I lose the connection. Restarting PuTTY doesn't do anything, I need to unplug the RPi and then plug it back in - but of course the same thing happens again.

I tried the PuTTY setting keepalives, but it doesn't really matter because I can be in the middle of typing and lose connection.

I've logged into my router and once saw the IP address (reserved) flicker on and off for a bit. Then it stayed on so I tried reconnecting with PuTTY and it worked for a minute or two before dropping again.

Seems like the issue is probably on the RPi's side. Possibly a bad WiFi dongle, but I'd love some info on this. For example, is there a sleep timer or something? Is there a way to force it to be always on?

bredman
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm

Re: intermittent wifi

Mon Oct 22, 2012 9:34 am

Once up and running, a WiFi connection should be rock-solid and should automatically reconnect if there is any interference or signal loss.

If this does not happen, the most likely culprit is a weak power supply. A WiFi device uses a lot of power (100 to 200mA) while transmitting. This could overload the power supply, especially if there is a polyfuse in the supply line. This can cause a brownout where one part of the system thinks that the connection is active and another thinks it has failed. In this case, the connection is not repaired and just sit there doing nothing.

The solution? Make sure that you use a good power supply for the WiFi device. Use a powered USB hub if the WiFi device does not have a power input.

gavofyork
Posts: 2
Joined: Tue Oct 23, 2012 8:23 am

Re: intermittent wifi

Tue Oct 23, 2012 8:36 am

I'm having exactly this problem too - the wifi will drop out after approx. one hour, and the Pi apparently requires a reboot to fix it. In particular, unloading/reloading the wifi devices's modules doesn't help.

I have two power units (a good-quality 1A supply to the Pi itself and a secondary 2A supply to my USB hub), so I can't imagine it's a power issue.

I've tried two different USB wifi cards (Ralink RT2870/RT3070 and D-Link DWL-G122); both fail in apparently the same way. I've also tried two different Pis (the recently released 512MB version as well as an original mobel B). I've tried stock speed and turbo - no change.

I've included the dmesg output from an example session at http://pastebin.com/PLFC2xFZ - perhaps it might help diagnose the problem.

Gav.

miguel_mike
Posts: 6
Joined: Mon Dec 10, 2012 10:27 pm

Re: intermittent wifi

Wed Dec 12, 2012 9:12 pm

Hi, i have exactly the same problem. My Wi-Fi signal is weak and sometimes will get interrupted. If the connection is interrupted, i have to execute "ifup wlan0" and it will reconnect. However if i am connected with putty, this is obviously impossible due to a non-existant connection. The solution seems pretty simple:
How do you execute "ifup wlan0" when there is no connection?
Answer please. I suppose you can program a script of some kind.

efflandt
Posts: 359
Joined: Mon Dec 03, 2012 2:47 am
Location: Elgin, IL USA

Re: intermittent wifi

Thu Dec 13, 2012 7:01 am

Check /var/log/syslog to see if something is interrupting USB (or ethernet which can indicate a USB problem even if using WiFi). In that case a simple ifup wlan0 using sudo or as root may do nothing.

I have that issue with some SD cards, and while a class 10 card may draw more power, I have not figured out why I have that problem with an 8 GB class 4 SD similar to (2) 16 GB class 4 cards from same manufacturer that work fine for an indefinite period.

Kronalias
Posts: 13
Joined: Sat Dec 22, 2012 4:39 pm

Re: intermittent wifi

Sat Dec 22, 2012 4:52 pm

I had a similar problem with my new RPi, which is running headless. Now I check every minute for wifi, and if it's not there I bring it up automatically.

You'll have to set up a cron job to run the script once a minute - just execute:

Code: Select all

crontab -e
and add this line at the end:

Code: Select all

*/1 * * * * /home/pi/my/scripts/wifi-check.pl >> /mnt/ramdisk/wifi-check.log
Note that you'll have to change /home/pi/my/scripts/wifi-check.pl to wherever you out the script, and change /mnt/ramdisk/wifi-check.log to wherever you want the log.

Here's the code - download is somewhere and make it executable:

Code: Select all

#!/usr/bin/perl

# NAME      wifi-check.pl
# AUTHOR    Kronalias
# PROVIDES  Checks to see if WiFi has a network IP and if not restarts WiFi
#
# CRONTAB   Run wifi-check.pl every minute
#           */1 * * * * /home/pi/my/scripts/wifi-check.pl >> /mnt/ramdisk/wifi-check.log
#
# HISTORY
# 1.01 - Base version
my $name = 'wifi-check.pl';
my $version = 1.01;

use strict;
use warnings;

my $wlan = 'wlan0';

use POSIX "strftime";
print strftime("%H:%M:%S %a %d %b %Y", localtime(time())) . ' ' . $name . ' ' . $version . ' ';


if (`ifconfig wlan0 | grep "inet addr:"`) {
  print "Up\n";
} else {
  print "Down\n";
    `sudo ifdown $wlan`;
    sleep 5;
    `sudo ifup --force $wlan`;
}

exit;
HTH, K

stephank
Posts: 6
Joined: Thu Jan 17, 2013 7:15 pm

Re: intermittent wifi

Thu Jan 17, 2013 10:12 pm

I have the same problem. However, I have noticed that while I'm experiencing these intermittent wifi drop outs, I can still ping the router and other devices on the network from the Pi. Everything seems fine from the Pi's perspective. A reboot usually fix the problem, and then after a few minutes the problem occures again.

I'm using a Linksys WUSB54GC on a power USB hub.

Return to “Networking and servers”