Cutting the Wire – WiFi configuration

There may be cases where you will not have Ethernet cable available to have you RPi connected to the internet. Raspberry Pi without network connection would be something really odd :) So how to get it connected without a wire? Well, you can buy inexpensive USB wifi and and follow our tutorial to have it set up. Unfortunately, you need to be connected to the internet when executing some of the commands (apt-get) or you need to download these packages earlier and install it in offline mode, but it gets a bit more complicated.

Ok, that’s enough. Let’s get to work.

Before you buy any WiFi USB dongle, make sure it is compatible with Raspberry Pi. See list of devices here.

Ok, so you bought it. Now, connect it to powered USB hub (you may try connecting this to RPi directly but you may encounter stability issues if your power supply is not “powerful” enough).

If Raspberry is now off, turn it on.

Let’s have a look if our WiFi dongle was detected:

You can see device 005 as:
ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter

If your device description says “Unknown device”, you can update your local usb device definition by running

In our case, from lsusb output, we know that our WiFi dongle is based on Realtek chipset.
If you have different chipset, you can get the list of driver modules in the output of

or go to this site and look for appropriate driver package name.

Execution of apt-cache search wireless alone will give you also idea what network tools you have also available (lke wicd).

Ok, let’s start with updating our packages.

Make sure you have all items below installed (you can just run these statements and if you have them installed already, these commands will not do anything):

Fist one installs tools for wireless network management. The second one installs component required to connect to WPA/WPA2 secured network. The third one installs drivers for our WiFi (remember, you may need different package than firmware-realtek – it depends on your WiFi chipset).

If installation went fine, you should be able to see the following (or similar) output when executing iwconfig:

Now let’s check what networks we have in range:
Check also WiFi configuration using XBMC at the end of this article

Ok, so if you see the networks around you, it means that your WiFi is already working. Now we need to configure our WiFi to connect to our network. I assume you are connecting to WiFi router with WPA2 security. My network’s name is tociek-net.

Before we configure the interface we need to create WPA security configuration file.

For security reasons you may want to remove the password written in open text.

Now, go to /etc/network/interfaces and add the following lines:

Description of the above files:
allow-hotplug starts interface when the kernel detects a hotplug event from the interface
auto starts interface upon start of the system
iface ... defines network confguration – here we set wlan0 to use DHCP (dynamic IP assignment)

Next two lines are quite interesting… pre-up command causes wpa_supplicant daemon to start before wlan0 interface is raised. You need to pass wpa configuration file after -c switch.
The next line kills the deamon after wlan0 interface is shut down.

Ok, now we’re ready to connect to the network:

We can check connection status:

… and disable WiFi network.

Static ip configuraton is very similar to what you could see above. /etc/network/interfaces would look like this:


WiFi setup with XBMC
(you need to have drivers installed first, but skip wpa and interfaces configuration)


XBMC has a Network-Manager plugin. You can install it by going to:
System->Settings->Add-ons->Get add-ons->XBMC.org Add-ons->Program Add-ons->Network-Manager

After the installation go to Programs->Network-Manager. Initial screen should look something like this:

List of defined networks - Initial Network-Manager Screen

List of defined networks – Initial Network-Manager Screen

Here you can select Add to scan for available networks and connect to one:

List of available networks - Network-Manager Screen

List of available networks – Network-Manager Screen

Select desired network and provide network passkey, if needed. You can also add WiFi access point that is not broadcasting its SSID. In order to do that select Add Hidden.

Now you can set Rpi WiFi without connecting via network to your RPi – remote to CEC compatible device should do the trick :) Enjoy!

Here is your raspberry pi ampilight system!
  • Pingback: Raspberry Pi with RTL8188CUS 802.11n wifi adapter | Heimic()

  • Kirkov

    Thanks Jacek,

    I’ve been screwing around with a wifi adapter (second one I’ve bought) and this post got me closer than anything else I’ve tried.

    It all looks great but when I unplug eth0 SSH drops out.

    Any ideas?

    pi@raspberrypi ~ $ iwconfig wlan0
    wlan0 IEEE 802.11bg ESSID:”ManusIsland” Nickname:””
    Mode:Managed Frequency:2.437 GHz Access Point: 00:60:64:43:22:2D
    Bit Rate:54 Mb/s Sensitivity:0/0
    Retry:off RTS thr:off Fragment thr:off
    Power Management:off
    Link Quality=100/100 Signal level=100/100 Noise level=0/100
    Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
    Tx excessive retries:0 Invalid misc:0 Missed beacon:0

  • ben houghton

    This is very helpful Jacek,
    but I’m not getting anywhere. I bought a TP-Link WN725n adapter, bought specifically coz it was on the list of ‘works out of the box’. It doesn’t, sadly.
    I have followed your commands here, but when I type iwconfig I get the following response:-
    lo no wireless extensions
    eth0 no wireless extensions.

    I’m a complete noob as regards Linux so am now stuck.
    Can you offer me any advice, please?

    Thanks
    Benjiboy

    • Jacek

      Hi, there are two different versions of this adapter. Try installing it first using one of the other tutorials on this website. Let me know if that helps (this tutotial was for v1 of the adapter based on 8188cus chipset)

      • ben houghton

        Hello Jacek.
        I tried the 3 commands in your other post. The download seemed to work okay saying ‘8188eu.ko saved’. The 2nd command produced no response, but the 3rd responded ‘FATAL:module 8188eu not found’. Should I have been in a specific folder or something?