Introduction: Raspberry Pi 2 Wifi Struggles and Solution

I have a few Raspberry Pi 2 boards running various projects that I setup over the past 18 months. A couple of these have been published here on instructables:


A couple of boards used older builds of Raspbian and did not have issues connecting to my obsolete WEP Wifi wireless network.

But it was high time to bring my Wifi network up to more modern standards such as the WPA2-PSK [AES] .

With this change, the new Wifi network was up and operational, but this caused my Raspberry Pi boards to drop connections to the Wifi network.

In this Instructable, I will walk you through the struggles and solution of setting up the Raspberry Pi 2 to work with the WPA Wifi network.

Step 1: Yet Another Raspberry Pi Wifi Article!

Yep! I asked that question myself after having browsed the internet. But the problem here is that none of the solutions actually worked for me straight away.

And the research sometimes got out of hand and took me off track and away from the actual objective. This was putting me in a situation in which I was trying to resolve things that did not exist to begin with.

Therefore, this article is a summary of how to get a WPA-PSK Wifi network up and running quickly on the Raspberry Pi 2.

Let's get our Pi 2 connected!

Step 2: The Hardware and Software Setup

The set up is being listed here because some of my hardware is at least 2 years old and it's good practice to make it clear that this solution has been tried and tested on a finite set of hardware and software combinations.

As of today, I do not own the latest Raspberry Pi 3 board (with built-in Wifi) and therefore this version of the Pi is not within the scope of this IBLE.

Similarly, the very old version of Raspberry Pi A+ and B versions have not been tested and therefore are not in scope as well.

Here below is a list of hardware and software that I currently use:

The Raspberry Pi 2, Model B+ with a Raspbian build that's at least 1.5 years old

The Raspberry Pi 2, Model B with a Raspbian-Jessie build that's at least a year old

The Raspberry Pi 2, Model B with the latest build of the popular RetroPie OS

The ubiquitous Edimax Wireless USB dongle, few of which were lying in my parts bin for a couple of years

A quick (but dated) comparison of various Raspberry Pi boards can be found here.

Step 3: Getting the Research Back on Track

During my search for a solution online, I ran into discussions that stated that some Wifi USB dongles were manufactured with "exotic" chipsets and configuring them to work was not a straight forward task.

This would be true if I did possess any such exotic USB dongles. But if my Edimax USB adapter was working flawlessly over the past two years and getting it to function with an updated Wifi network required me to look into chipsets, I knew that my research had gone off track and off-objective.

Therefore, if you have any of the widely used USB dongles (such as Edimax), this solution should work without you having to get into nitty-gritty details of chip sets and crazy micro-level research.

Step 4: Making Changes to the Wifi Network

I made a few attempts to get the Pi working with my Wifi network after it was upgraded to the WPA2-PSK [AES] standard.

For some reason, none of the configurations worked. After more research, I decided to step my Wifi network down to support the older WPA-PSK [TKIP] standard.

With a few quick changes to my routers Wifi settings, I was able to set up the home Wifi network to WPA-PSK [TKIP] + WPA2-PSK [AES] standard.

The password (not to be confused with Passphrase) that I originally used for legacy WEP settings is almost 30 characters long, and therefore I decided to retain the same for the new Wifi settings as well.

Step 5: Wrestling With the Wpa_supplicant Utility

Because I was working with a Raspbian OS build that was at least a couple of years old, I decided to refer to the wpa_supplicant documentation that was locally available on my Pi at this location.

/usr/share/doc/wpasupplicant/examples

Based on this documentation, I played around with a number of setting changes to the wpa_supplicant.conf file.

No matter, how I changed the settings, the Pi simply refused to connect to the internet.

The error message being output frequently reported a missing wpa_supplicant file or directory despite the fact that this configuration file existed at the path:

/etc/wpa_supplicant/wpa_supplicant.conf

In addition, I was able to edit this file using nano and configure my Wifi settings.

There was no change in the situation ever after having tried out all configurations listed in the documentation and the above error continued to show up.

The next available option was to set up the Wifi connection by completely disregarding the wpa_supplicant utility.

Step 6: Losing the Wpa_supplicant Utility!

The next option was to bypass the wpa_supplicant utility entirely, and work directly with the network interfaces configuration located at this path:

/etc/network/interfaces

Which brings us to the discussion of Password Vs. Passphrase:

I thought I'll explicitly mention this here because this is one aspect that I completely misunderstood.
As my WiFi was set to the obsolete WEP standard for a very long time, I mistook the "password" to be the same as the "passphrase" setting!

Not correct!

After some more research, it was clear that the passphrase is something that needs to be derived using a combination of the current WiFi SSID and password using a utility named wpa_passphrase like so:

~ $ sudo wpa_passphrase SSID_NO_DOUBLE_QUOTES PASSWORD_NO_DOUBLE_QUOTES

Note that you should specify the name of your SSID and Wifi password without enclosing them in double quotes.

Running the above command results in an output that looks similar to the following:

network={	
	ssid="MY_SSID_INSIDE_DOUBLE_QUOTES"
	
	#psk="MY_VERY_LONG_PASSWORD_INSIDE_DOUBLE_QUOTES"
	
	psk=9d24321fad5e92de16581d4129g1b8dd2f47c6510953a68e95b1b6d99f5e95ef
}

Contrary to the inputs to the wpa_passphrase command, the SSID and original password will be output surrounded by quotes .

The original password however is automatically commented out with a # sign

The third line in the output, also named psk (acronym for Pre-shared Key) is the Passphrase and unlike the other two outputs will not be surrounded by quotes.

The passphrase will be different from the original password and this is what we will be using to configure the WiFi settings directly in the /etc/network/interfaces configuration file.

Step 7: Configuring the Wifi Settings

The next step in the configuration is to edit the /etc/network/interfaces configuration file using the nano text editor and plug in the PSK setting.

$ sudo nano /etc/network/interfaces

Comment out or delete the wpa_supplicant settings with the # sign. Add a useful comment to record the intent of the setting change:

#LOSE the wpa_supplicant utility by commenting out these settings!<br>#allow-hotplug wlan0<br>#iface wlan0 inet manual
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp

Configure the Wifi settings using the PSK value generated in the last steps:

# BYPASSED wpa_supplicant - Wifi configuration defined directly this file
# Set the iface setting to use "dhcp" 
allow-hotplug wlan0
iface wlan0 inet dhcp         
wpa-ssid MY_SSID_NO_DOUBLE_QUOTES          
wpa-psk 9d24321fad5e92de16581d4129g1b8dd2f47c6510953a68e95b1b6d99f5e95ef

Save and close the /etc/network/interfaces file.

With the settings saved, the configuration file should look like the one in the image.

Step 8: Restart Wifi on the Pi

Bring the network interface down with the ifdown command:

 ~ $ sudo ifdown wlan0
Internet Systems Consortium DHCP Client 4.2.2
Copyright 2004-2011 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/wlan0/74:da:38:0f:9b:c8
Sending on LPF/wlan0/74:da:38:0f:9b:c8
Sending on Socket/fallback|
DHCPRELEASE on wlan0 to 10.0.0.1 port 67
send_packet: Network is unreachable
send_packet: please consult README file regarding broadcast address.

Restart the network interface down with the ifup command:

~ $ sudo ifup wlan0
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
Internet Systems Consortium DHCP Client 4.2.2
Copyright 2004-2011 Internet Systems Consortium. All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/ Listening on LPF/wlan0/74:da:38:0f:9b:c8
Sending on LPF/wlan0/74:da:38:0f:9b:c8
Sending on Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPOFFER from 10.0.0.1
DHCPACK from 10.0.0.1 bound to 10.0.0.15 -- renewal in 38873 seconds.

Despite the "Operation not permitted" message in the output, the Pi will be able to reach your router and connect to the web!

Perform a couple of simple ping tests. One that hits the local router, and another to hit something like google.com in the public domain.

Hit Ctrl+C anytime to end the ping test.

Step 9: Next Steps

The final confirmation would be to open the browser on the Raspberry Pi and surf the internet.

With the internet working on my Raspberry Pi B+ board, I was able to replicate this solution into the two other Raspberry Pi B boards successfully!

Now that my Pi boards are back to working order, the next step would be give one more shot at trying to get this solution to work with the WPA2-PSK [AES] Wifi network.

Thanks for reading my IBLE and good luck with the WiFi connection! :-)

Comments

About This Instructable

688views

15favorites

License:

Bio: I'm a Mechanical Engineer turned IT Professional . I came into the Information Technology world because someone challenged me to. But at heart, I'm ... More »
More by andymenon:OctoPrint Webcam Bracket for Creality CR-10An Unconventional 3D Printed Retropie Arcade - Part 1 of 2Monoprice Mini: Remove Broken Filament From Nozzle
Add instructable to: