Fix the "Invalid Argument" Error on Raspberry Pi

 


 

I finally cracked and purchased my first Raspberry Pi. NOOBS made installing Raspbian as easy as pie but when it came time to hop on my home wireless network things went south quickly. When I tried to join my network via the GUI panel, I kept getting an error that said "invalid argument".

TLDR: Networks with SSIDs containing abnormal characters (e.g. emojis) cause problems. In order to join a problematic network you must do some manual configuration using a byte representation of the network's name.

In my case, my home network's name is 🍍Pinedapple. Yes, there is a 'd' in there. Needless to say, renaming the network to something more sterile was not an option.

 This is how the network shows up in the network panel. 

This is how the network shows up in the network panel. 


Step 1

The first thing we need to do is copy the name of your wireless network.

sudo iwlist wlan0 scan | awk '/ESSID/'
 My network is the first in the list. Copy the string (without the quotes) after "ESSID:"

My network is the first in the list. Copy the string (without the quotes) after "ESSID:"

Find your network in the list and copy it. My network name is \xF0\x9F\x8D\x8DPinedapple


Step 2

Using python, we will store a different representation of the network name into a temporary text file that you may delete later.

python

This will open the python interpreter. Add the following lines to write the name to a temporary file. Be sure to replace the network name with your own!

ssid = '\xF0\x9F\x8D\x8DPinedapple'
file = open('ssid-tmp.txt', 'w')
file.write(ssid)
file.close()
quit()
 Here is what my temporary file contains after exiting the python interpreter

Here is what my temporary file contains after exiting the python interpreter


Step 3

Let's convert the temporary file to hex with the xxd utility

xxd ssid-tmp.txt

This will print out a hex version of the temporary file. Copy the hex value after the colon, removing the spaces.

 In my case, the value I want to copy is f09f8d8d50696e65646170706c65

In my case, the value I want to copy is f09f8d8d50696e65646170706c65


Step 4

Now we need to manually configure the network settings. To do this, we will be adding a network section to /etc/wpa_supplicant/wpa_supplicant.conf.

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Then, paste the following settings into the bottom of the file. Be sure to replace the SSID value with your own from the previous step. You will also need to add your network's password.

network = {
    ssid=f09f8d8d50696e65646170706c65
    psk="YOUR NETWORK PASSWORD HERE"
    key_mgmt=WPA-PSK
}

It is important that you do NOT have quotes around your SSID.


Step 5

Let's see if it worked!

sudo ifdown wlan0
sudo ifup wlan0

It might take a minute or two but, if everything worked, you should be connected automatically! If you have issues, try rebooting the machine. If that doesn't do the trick, go back and double check each step above. It's very easy to copy and paste the wrong values.