27

I was finally able to get my Raspberry Pi connected to a hidden SSID network (WPA2 Personal) using the below settings (not using wpa_supplicant.conf).

However, after a few hours it disconnects and does not reconnect.

  • Raspberry Pi B+, running NOOBS.
  • USB powered WiFi card (Ralink RT5370 chipset)
  • Connected to a hidden SSID (I'm not sure the hidden SSID has anything to do with this issue, might be a red herring)

Here is the log:

Feb  6 14:36:01 raspberrypi wpa_supplicant[1641]: wlan0: CTRL-EVENT-DISCONNECTED bssid=90:72:40:1c:ed:c8 reason=4
Feb  6 14:36:01 raspberrypi kernel: [33883.785257] cfg80211: Calling CRDA to update world regulatory domain
Feb  6 14:36:01 raspberrypi ifplugd(wlan0)[1634]: Link beat lost.
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: Executing '/etc/ifplugd/ifplugd.action wlan0 down'.
Feb  6 14:36:11 raspberrypi dhclient: Internet Systems Consortium DHCP Client 4.2.2
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: Internet Systems Consortium DHCP Client 4.2.2
Feb  6 14:36:11 raspberrypi dhclient: Copyright 2004-2011 Internet Systems Consortium.
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: Copyright 2004-2011 Internet Systems Consortium.
Feb  6 14:36:11 raspberrypi dhclient: All rights reserved.
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: All rights reserved.
Feb  6 14:36:11 raspberrypi dhclient: For info, please visit https://www.isc.org/software/dhcp/
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: For info, please visit https://www.isc.org/software/dhcp/
Feb  6 14:36:11 raspberrypi dhclient: 
Feb  6 14:36:11 raspberrypi dhclient: Listening on LPF/wlan0/00:0f:60:01:de:14
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: Listening on LPF/wlan0/00:0f:60:01:de:14
Feb  6 14:36:11 raspberrypi dhclient: Sending on   LPF/wlan0/00:0f:60:01:de:14
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: Sending on   LPF/wlan0/00:0f:60:01:de:14
Feb  6 14:36:11 raspberrypi dhclient: Sending on   Socket/fallback
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: Sending on   Socket/fallback
Feb  6 14:36:11 raspberrypi dhclient: DHCPRELEASE on wlan0 to 192.168.128.254 port 67
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: DHCPRELEASE on wlan0 to 192.168.128.254 port 67
Feb  6 14:36:12 raspberrypi wpa_supplicant[1641]: wlan0: CTRL-EVENT-TERMINATING - signal 15 received
Feb  6 14:36:12 raspberrypi ifplugd(wlan0)[1634]: Program executed successfully.
Feb  6 14:36:14 raspberrypi ntpd[2157]: Deleting interface #2 wlan0, 192.168.128.122#123, interface stats: received=389, sent=396, dropped=0, active_time=33841 secs
Feb  6 14:36:14 raspberrypi ntpd[2157]: 192.96.207.244 interface 192.168.128.122 -> (none)
Feb  6 14:36:14 raspberrypi ntpd[2157]: 178.18.16.124 interface 192.168.128.122 -> (none)
Feb  6 14:36:14 raspberrypi ntpd[2157]: 204.2.134.164 interface 192.168.128.122 -> (none)
Feb  6 14:36:14 raspberrypi ntpd[2157]: 216.152.240.220 interface 192.168.128.122 -> (none)
Feb  6 14:36:14 raspberrypi ntpd[2157]: peers refreshed

Here is the /etc/network/interfaces

auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
    wpa-scan-ssid 1
    wpa-ap-scan 1
    wpa-key-mgmt WPA-PSK
    wpa-proto RSN WPA
    wpa-pairwise CCMP TKIP
    wpa-group CCMP TKIP
    wpa-ssid "Na*****"
    wpa-psk *********************************************************
Micah
  • 501
  • 1
  • 4
  • 10

9 Answers9

13

The only way I as able to resolve this issue was to write a shell script that is run every minute by a cron job. It checks if the network is down, if so, reconnects it. It has worked very well for the last week.

#!/bin/bash

MY_PATH="`dirname \"$0\"`"              # relative
LOG_PATH="`( cd \"$MY_PATH\" && cd .. && pwd )`/log/network.log"
now=$(date +"%m-%d %r")

# Which Interface do you want to check
wlan='wlan0'
# Which address do you want to ping to see if you can connect
pingip='google.com'

# Perform the network check and reset if necessary
/bin/ping -c 2 -I $wlan $pingip > /dev/null 2> /dev/null
if [ $? -ge 1 ] ; then
    echo "$now Network is DOWN. Perform a reset" >> $LOG_PATH
    /sbin/ifdown $wlan
    sleep 5
    /sbin/ifup --force $wlan
else
    echo "$now Network is UP. Just exit the program." >> $LOG_PATH
fi
Micah
  • 501
  • 1
  • 4
  • 10
8

This is expected behaviour; WiFi can not be guaranteed 100% of the time.

This applies to Raspbian Wheezy prior to 2015-05-05 for later (and Jessie) See How do I set up networking/WiFi/Static IP

If you want it to reconnect automatically after loss of connectivity use wpa-roam in conjunction with wpa_supplicant.conf)

PS It is not sensible to publish your SSID and PSK

/etc/network/interfaces

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface home inet dhcp
iface default inet dhcp

/etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    scan_ssid=1
    ssid="xxx"
    psk="yyy"
    id_str="home"
    proto=RSN
    key_mgmt=WPA-PSK
    pairwise=CCMP
    auth_alg=OPEN
    eap=MD5
}
Milliways
  • 62,573
  • 32
  • 113
  • 225
5

Check your power_save settings; e.g.:

pi@pebbles:~ $ sudo iw dev wlan0 get power_save
Power save: on

If it's on, you can temporarily disable it with sudo iw dev wlan0 set power_save off.

To permanently disable it, see this answer for details.

Thiago Figueiro
  • 151
  • 1
  • 5
4

As suggested you can use wpa-roam, though I would recommend to use wicd or network manager. They take care of all the settings, they also deal with multiple networks and are more user friendly.

For instance wicd has a curses gui that you can install with:

sudo apt-get install wicd-curses

And run with:

wicd-curses
tfjgeorge
  • 151
  • 2
3

was having the same issues with disconnect... has to do with the wireless adapter. My linksys ae3000 disconnects every few days. I slightly modified it to work with my motion usb cameras and nfs share plus added email notification.

Crontab entry:

*/1 * * * * /root/netcheck.sh > /dev/null 2>&1

Modified Script:

#!/bin/bash

LOG_PATH="/var/log/network.log"
now=$(date +"%m-%d %r")

# Which Interface do you want to check (wlan = wireless, eth0 = ethernet)
iface='eth0'
# Which address do you want to ping to see if you can connect
pingip='google.com'

# Perform the network check and reset if necessary
/bin/ping -c 2 -I $iface $pingip > /dev/null 2> /dev/null
if [ $? -ge 1 ] ; then
    echo "$now Network is DOWN. Perform a reset" >> $LOG_PATH
    /sbin/ifdown $iface
    sleep 5
    /sbin/ifup --force $iface
    sleep 5
    /bin/mount -o remount /data (reconnects my NAS nfs share)
    sleep 2
    /etc/init.d/motion restart  (restarts motion to clean hung processes)
    sleep 3
    /etc/init.d/motion restart  (2nd restart for sanity sake, sometimes 1st restart doesn't pan out)
    mail -s "`hostname` $iface recovered" xxxxxxxxx@gmail.com < /dev/null  (send me an email so I know about this)
fi
2

When I found my wifi down I ran dhcpcd:

sudo dhcpcd

This command turned it back on. I use this command in a loop that runs twice a day, seems to work great.

zeaper
  • 21
  • 1
2

I changed the time settings and it all started working for me.

Preferences-> Raspberry Pi Configuration-> Localisation Tab

I made sure all 4 of the options were set correctly for my location.

plyons126
  • 21
  • 1
1

disable wifi power management should help, as discussed here: https://discourse.osmc.tv/t/pi-3-wifi-unstable/14171/25

Ming Tsai
  • 11
  • 1
1

Had the same problem, solved it by making my PI ping Google once every minute.

run sudo crontab -e

Add this to the end of the file

* * * * * /bin/ping -c2 -I wlan0 8.8.8.8 >/dev/null
birgersp
  • 121
  • 5