Wednesday, January 9, 2013

How to setup a Raspberry Pi with a hidden network using a Edimax EW-7811Un

If you are looking for a wireless adapter for the Raspberry Pi, the Edimax EW-7811Un is reasonably priced at $12.99 ($9.99 w/ Amazon Prime) and is supported with Raspbian "wheezy" 3.2.27+ kernel.  There were driver issues with earlier versions of Raspbian, but luckily you won't have to worry about installing drivers with any Raspbian image dated 2012-12-06 or older.

After you install Raspbian to a SD card (OSX command: sudo dd if=~/2012-12-16-wheezy-raspbian.img of=/dev/disk1 bs=1m), boot up the Raspberry Pi and perform the following:
  1. Launch a repository update
    $ sudo apt-get update
  2. Run a system upgrade
    $ sudo apt-get upgrade
  3. Make sure that the latest Raspberry Pi firmware version is installed
    $ sudo apt-get install raspberrypi-bootloader
  4. Install the wpa_supplicant utility
    $ apt-get install wpasupplicant
WLAN setup and configuration for a hidden SSID wifi network
  1. Generate a PSK version of your WLAN password with wpa_passphrase utility
    $ wpa_passphrase "<Your Wifi SSID>" "<Your Wifi PASSWORD>"
    (Quotes are needed for whitespace)
  2. Edit /etc/network/interfaces and add the following:######################################
    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 "<Your Wifi SSID>"
       wpa-psk <Your PSK Value>

    iface default inet dhcp
  3. Save the changes and shutdown the Raspberry Pi.
  4. Unplug the ethernet cable and plug in the Edimax EW-7811Un wifi dongle.
  5. Power on the Raspberry PI and wait for the wireless to get a IP.
My router statically maps a IP to the network interfaces MAC address, that is why I chose to allow Linux to run DHCP.  If there are any issues, some helpful commands to detect hardware are the following:


  1. Thanks for your explanations. After some hours of fiddling around I noticed that my problems were caused by my hidden ssid. So I found your blog and now it works like a charm.


  2. didn't work for me; now can't connect with Ethernet either

  3. Good,

    I have question,

    Is that possible to power up the raspberry pi with both wlan0 and eth0 ??

  4. I was too lazy to go get the cord so I skipped the apt-get steps due to no network connection. I had to put double quotes around SSID and password to get it to work. Utilities look good. Thanks.

  5. Execlent worked right away for me very hassle free the only thing that I would like to add is when you do your wpa_passphrase it to type it like this wpa_passphrase "Your Wifi SSID" "Your Wifi PASSWORD" as if like me you have a space in your ssid it then thinks that the second part of your ssid is your wifi password if you put in the quots then its happy :) Thank you very much!!!

    1. Good point, I updated the blog post. Thanks Steven.

  6. Hmm, I edited as above and now can't connect via Ethernet or wifi. I think it's b/c I have my router mac authentication on and I didn't add the wifi dongle prior to restarting. I'm thinking I'll need to reformat my SD card to get everything working again. What do you think?

    1. just add the dongle MAC, power down the Pi and restart the router. See if that works. Reformatting the SD card is a bit of a overkill.

  7. Can anyone explain what I am missing here? XXX XX represents my router SSID and xxx12345 my password.

    pi@raspberrypi ~ $ wpa_passphrase XXX XX xxx12345
    Passphrase must be 8..63 characters
    pi@raspberrypi ~ $ wpa_passphrase
    -bash: syntax error near unexpected token `<'

    1. Use double quotes (e.g. "XXX XX"). I updated my blog to reflect that change. Personally I don't like having whitespace in any of my SSID's. That is the reason I never had double quotes in my original blog post.

  8. I get

    root@raspberrypi:/home/pi# ifup --force wlan0
    ioctl[SIOCSIWAP]: Operation not permitted
    ioctl[SIOCSIWENCODEEXT]: Invalid argument
    ioctl[SIOCSIWENCODEEXT]: Invalid argument

    with my Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter on my raspberry pi b

    1. Looks like some steps were missed. Try to work through the tutorial again and see if you get the same errors.

  9. Thanks!! your solution worked very well !

    I tried a couple of times with "wpa_gui" -- but no luck.

    1. I have been playing with this all day... Then I found your posting.
      Works like a champ

  10. Hi, thanks for your article, I don't know exactly why the usual "wpa_supplicant.conf" file wouldn't work (as it does on my regular linux PC) because the wlan0 didn't want to connect to my hidden SSID but it flawlessly worked with your method (basically, you put everything in the /etc/network/interfaces file instead of using wpa_supplicant.conf).

    So, even if I'd like to understand the relying cause of this, I just would like to say THANK YOU VERY MUCH because know, my model A (without ETH) is usable :)


  11. Worked like a charm with my EDUP wifi pen. Thanks a lot

  12. I am trying to access an "open" wifi, where a password is not needed to connect. I can determine the SSID and enter it in the interfaces file but not a password. Reboot is requiring a wpa-psk parameter it appears. Any way I can still connect with my Raspi? My Windows notebook connects just fine! Must be some way my Raspi can also?

  13. Thank you very, very much, it works perfectly

  14. Worked flawlessly on my EW-7811Un. Thanks

  15. Thanks! Works great, except now the WiFi is disconnecting after a few hours and not coming back up:

    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.

  16. Thanks very much! So, If i connect to 2 different networks, Can you help me do this?

  17. Thanks, If i connect to many hidden network, how do?

  18. Thanks! Your configuration worked great on my RPi2.

  19. Thanks! Your configuration works great on my RPi2.