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:

pi@raspbmc:~$ lsusb

Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.

Bus 001 Device 004: ID 1a40:0101 Terminus Technology Inc. 4-Port HUB

Bus 001 Device 005: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter

Bus 001 Device 006: ID 0951:1653 Kingston Technology Data Traveler 100 G2 8 GiB

Bus 001 Device 007: ID 1058:0748 Western Digital Technologies, Inc.

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

sudo update-usbids

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

apt-cache search wireless | grep firmware

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.

sudo apt-get update

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):

sudo apt-get install wireless-tools sudo apt-get install wpasupplicant sudo apt-get install firmware-realtek

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:

pi@raspbmc:~$ iwconfig wlan0 unassociated Nickname:""

Mode:Managed Frequency=2.437 GHz Access Point: Not-Associated

Sensitivity:0/0

Retry:off RTS thr:off Fragment thr:off

Power Management:off

Link Quality:0 Signal level:0 Noise level:0

Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0

Tx excessive retries:0 Invalid misc:0 Missed beacon:0

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

pi@raspbmc:~$ iwlist wlan0 scan wlan0 Scan completed :

Cell 01 - Address: 00:1D:7E:FB:BA:F1

ESSID:"tociek-net"

Protocol:IEEE 802.11bg

Mode:Master

Frequency:2.437 GHz (Channel 6)

Encryption key:on

Bit Rates:54 Mb/s

Extra:wpa_ie=dd1c0050f20101000050f20202000050f2040050f20201000050f2020000

IE: WPA Version 1

Group Cipher : TKIP

Pairwise Ciphers (2) : CCMP TKIP

Authentication Suites (1) : PSK

Extra:rsn_ie=30180100000fac020200000fac04000fac020100000fac020000

IE: IEEE 802.11i/WPA2 Version 1

Group Cipher : TKIP

Pairwise Ciphers (2) : CCMP TKIP

Authentication Suites (1) : PSK

Quality=100/100 Signal level=100/100

Cell 02 - Address: 00:21:27:E9:EA:00

ESSID:"Jacek"

Protocol:IEEE 802.11bg

Mode:Master

Frequency:2.437 GHz (Channel 6)

Encryption key:on

Bit Rates:54 Mb/s

Extra:wpa_ie=dd1a0050f20101000050f20202000050f2020050f20401000050f202

IE: WPA Version 1

Group Cipher : TKIP

Pairwise Ciphers (2) : TKIP CCMP

Authentication Suites (1) : PSK

Extra:rsn_ie=30180100000fac020200000fac02000fac040100000fac020100

IE: IEEE 802.11i/WPA2 Version 1

Group Cipher : TKIP

Pairwise Ciphers (2) : TKIP CCMP

Authentication Suites (1) : PSK

Preauthentication Supported

Quality=61/100 Signal level=54/100

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.

pi@raspbmc:~$ wpa_passphrase tociek-net my_secret_passwd > sudo /etc/wpa.conf pi@raspbmc:~$ cat /etc/wpa.conf network={

ssid="tociek-net"

#psk="my_secret_passwd"

psk=4b7084a26fea96aaf67518820cc1151fb8f47c5fc0674cd6e877a2ecd70b596e

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:

allow-hotplug wlan0

auto wlan0

iface wlan0 inet dhcp pre-up wpa_supplicant -B w -D wext -i wlan0 -c /etc/wpa.conf post-down killall -q wpa_supplicant

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:

pi@raspbmc:~$ sudo ifup wlan0

rfkill: Cannot open RFKILL control device 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/a0:f3:c1:08:21:ac

Sending on LPF/wlan0/a0:f3:c1:08:21:ac

Sending on Socket/fallback

DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7

DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 14

DHCPREQUEST on wlan0 to 255.255.255.255 port 67

DHCPOFFER from 192.168.1.1

DHCPACK from 192.168.1.1

Reloading /etc/samba/smb.conf: smbd only.

bound to 192.168.1.137 -- renewal in 39240 seconds.

We can check connection status:

pi@raspbmc:~$ iwconfig wlan0

wlan0 IEEE 802.11bg ESSID:"tociek-net" Nickname:""

Mode:Managed Frequency:2.437 GHz Access Point: 00:1D:7E:FB:BA:F1

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

… and disable WiFi network.

pi@raspbmc:~$ 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/a0:f3:c1:08:21:ac

Sending on LPF/wlan0/a0:f3:c1:08:21:ac

Sending on Socket/fallback

DHCPRELEASE on wlan0 to 192.168.1.1 port 67

Reloading /etc/samba/smb.conf: smbd only.

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

allow-hotplug wlan0

auto wlan0

iface wlan0 inet static address 192.168.1.137

netmask 255.255.255.0

network 192.168.1.0

broadcast 192.168.1.255

gateway 192.168.1.1


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!

Continue reading here: Control Lightberry from Kodi/Xbmc Htpc over network

Was this article helpful?

0 0