4

I have a raspberry pi running raspbian. I got it connected to my home network via wifi without issue.

However, after returning home from work with the pi (it was powered on the whole day), it did not auto-reconnect to the network.

Here is my /etc/network/interfaces configuration:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

And here is my /etc/wpa_supplicant/wpa_supplicant.conf configuration:

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

network={
ssid="SSID"
psk="mypasswordishere"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}

Does anyone know how to make it auto-reconnect to a wifi network when it is in range?

Been frustrated over this...

  • If you left the network settings as they were it would work. See http://raspberrypi.stackexchange.com/a/37921/8697 If you have some reason to use the old settings use wpa-roam (this is from memory) but you also need to fix the other errors in your file. – Milliways Jan 11 '16 at 22:43
  • 1
    iface wlan0 inet dhcp should probably be iface wlan0 inet manual. But I'm not quite sure I understand your question. Do you want it to autoconnect to different networks or only automatically connect to your home network. Your wpa_supplicant.conf doesn't seem right either. I think auth_alg=OPEN is for WEP, but key_mgmt is set to WPA-PSK – Diederik de Haas Jan 12 '16 at 10:58
  • 2 alternatives. (bash script or configure settings) raspi.stackexchange: how to auto reconnect wifi – Alireza7am Jan 11 '16 at 19:41

2 Answers2

2

This is how I do it It works for Pi0, Pi, Pi2 & Pi3 (I haven't tried a Pi3 B+) and the latest images, and has worked for years!:

To configure Wi-Fi, copy /etc/wpa_supplicant/wpa_supplicant.conf from an existing device or create a new wpa_supplicant.conf like:

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

network={
        ssid="YOUR_SSID"
        psk="YOUR_PSK"
}

and copy it into the boot partition (accessible via most Windows machines).

Note: You may want to change your county ID for compliance. Done!

electron1979
  • 121
  • 11
0

Wicd adds a daemon that does that. When you connect, you can make that WiFi spot auto connect. You can also make any spot with the same ID auto connect. There is a curses version for terminals.

PaulF8080
  • 307
  • 1
  • 7
  • Do you have more details to make this a workable answer for OP? – dbmitch Nov 20 '16 at 23:49
  • All I did was install wicd because it was on my beagle bone. It is a self explanatory graphic interface that puts an icon on the top right of the screen on the bar. Each connection ID has a properties window. – PaulF8080 Nov 21 '16 at 05:16