1

Relative newbie, just completed my first simple sensor project that outputs data to the web whilst connected via Ethernet. Now I'm trying to move this setup to a WiFi connection which I thought might be the easy part, but I'm stuck...

I've played around with /etc/network/interfaces and /etc/wpa_supplicant/wpa_supplicant.conf, but I can't seem to get a connection via wlan0 whatever I do. I've tried multiple different options, with output for iconfig and current contents of these files below. When ifdown wlan0 I get ifdown: interface wlan0 not configured.

Any help much appreciated.

Update 06/09 - now added sudo iwlist wlan0 scan. I'm using SSID=VM321716-2G_EXT.

iconfig wlan0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 169.254.224.240  netmask 255.255.0.0  broadcast 169.254.255.255
    inet6 fe80::e1c9:f258:85c5:4e5a  prefixlen 64  scopeid 0x20<link>
    ether b8:27:eb:d2:05:21  txqueuelen 1000  (Ethernet)
    RX packets 383  bytes 62895 (61.4 KiB)
    RX errors 0  dropped 2  overruns 0  frame 0
    TX packets 521  bytes 63660 (62.1 KiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

/etc/network/interfaces

auto lo 
iface lo inet loopback

iface eth0 inet manual

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

allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

/etc/wpa_supplicant/wpa_supplicant.conf

country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

update_config=1

network={
 ssid="mySSID"
 psk="mypassword"
 key_mgmt=WPA-PSK
}

sudo iwlist wlan0 scan

wlan0     Scan completed :
      Cell 01 - Address: E8:FC:AF:3A:A9:90
                Channel:6
                Frequency:2.437 GHz (Channel 6)
                Quality=70/70  Signal level=-13 dBm
                Encryption key:on
                ESSID:"VM321716-2G"
....
      Cell 02 - Address: 34:8A:AE:CF:8F:B7
                Channel:1
                Frequency:2.412 GHz (Channel 1)
                Quality=36/70  Signal level=-74 dBm
                Encryption key:on
                ESSID:"BTHub5-ZP9Z"
....
      Cell 03 - Address: 9C:3D:CF:F1:AE:98
                Channel:6
                Frequency:2.437 GHz (Channel 6)
                Quality=48/70  Signal level=-62 dBm
                Encryption key:on
                ESSID:"VM321716-2G_EXT"
.....
  • what is the output from sudo iwlist wlan0 scan – MatsK Sep 6 '17 at 4:13
  • now updated with sudo iwlist wlan0 scan – Bob8224 Sep 6 '17 at 7:04
  • I cant see a ESSID that is named "mySSID" that wpa_supplicant.conf have. You need to add ESSID and password for your WiFi network into wpa_supplicant.conf – MatsK Oct 15 '17 at 9:56
  • And if you add a @ and my nic (MatsK) then I get a notice that you have made a new comment. Like this @MatsK – MatsK Oct 15 '17 at 9:58
1

Tweak /etc/wpa_supplicant/wpa_supplicant.conf

First, I would replace ssid="mySSID" with ssid="VM321716-2G_EXT". Also, make sure you replace mypassword with your wifi network's password.

If that didn't fix it, try removing the key_mgmt=WPA-PSK line from wpa_supplicant.conf because I don't think it's needed. If that fixes it, great! Otherwise, keep reading...


Check Password

It's dumb, but we all do it. Make sure you typed in the password correctly. If so, read on!


Link Local Address

This line in your ifconfig wlan0 output indicates a DHCP problem:

inet 169.254.224.240 netmask 255.255.0.0 broadcast 169.254.255.255

IP addresses in that 169.254.x.x range (Link Local) is what computers use when they failed to get an address via DHCP and there was no static fallback address configured.

Check dhcpcd

Assuming the other computers on your wifi are able to get to the Internet just fine, it's likely an issue on the raspberry pi.

dhcpcd is the service that handles getting a proper address from the DHCP server running on your wifi network (usually on the wifi router.) You can check to make sure it's running with sudo systemctl status dhcpcd:

pi@raspberry:~ $ sudo systemctl status dhcpcd
● dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled)
  Drop-In: /etc/systemd/system/dhcpcd.service.d
           └─wait.conf
   Active: active (running) since Sun 2017-05-07 21:45:24 UTC; 4 months 0 days ago
 Main PID: 591 (dhcpcd)
   CGroup: /system.slice/dhcpcd.service
           └─591 /sbin/dhcpcd -q -w

If it's not running, use sudo systemctl enable dhcpcd to make sure it runs at boot time and then reboot.

If it's already running, check the /etc/dhcpcd.conf configuration file to make sure it's not misconfigured. The default contents of that file are:

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
#duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
# Some interface drivers reset when changing the MTU so disabled by default.
#option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private

# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname
0

You can try out the below methods to troubleshoot the problem. This is very unprofessional but i hope it can help to pinpoint the problem.

***Trial and error method 0 (problem: need to reload /etc/network/interfaces)

  1. ifdown wlan0

  2. systemctl restart networking

  3. ifup wlan0

  4. ping 8.8.8.8

Trial and error method 1 (problem: need to run dhcpcd)

  1. Remove line key_mgmt=WPA-PSK

  2. ifup wlan0

  3. dchcpd wlan0

  4. ping 8.8.8.8

Trial and error method 2 (problem: need to run dhcpcd)

  1. Remove line key_mgmt=WPA-PSK

  2. Change line iface wlan0 inet dhcp

  3. ifup wlan0

  4. ping 8.8.8.8

Trial and error method 3 (problem: need wpa_supplicant & dhcp)

  1. Remove line key_mgmt=WPA-PSK

  2. ifup wlan0

  3. wpa_supplicant -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf

  4. dhcpcd wlan0

  5. ping 8.8.8.8

Trial and error method 4 (probelm: need to assign static address)

  1. Remove line key_mgmt=WPA-PSK

  2. ifup wlan0

  3. ifconfig wlan0 192.168.x.x (desired static ip address)

  4. route add default gw 192.168.x.x (ip of gateway)

  5. ping 8.8.8.8

Trial and error method 5 (problem: need wpa_supplicant & static)

  1. Remove line key_mgmt=WPA-PSK

  2. ifup wlan0

  3. wpa_supplicant -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf

  4. ifconfig wlan0 192.168.x.x (desired static ip address)

  5. route add default gw 192.168.x.x (ip of gateway)

  6. ping 8.8.8.8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.