terça-feira, fevereiro 12, 2013

Project 3 - Raspberry Pi - Enabling the Wi-Fi Dongle

The Ethernet connection is alive and kicking, but it's always nice to have total mobility around the house...

For that I needed to enable the Wi-Fi connection, which I did.

Following up on the last post "Setting up an headless X Windows", it was od paramount importance to get the Wi-Fi Dongle working. I've got a lot of projects, that depend upon this feature. Nowadays a device without Wi-Fi is not much more than a trinket.

By selecting the wi-fi config tool on the X-Windows, I was able to set-up it up. My Wi-Fi network is called "heimnetzwerk" (home network in German...lol ).

My wireless network parameters:
  • SSID = heimnetzwerk
  • Authentication protocol  =  WPA2 Personal (PSK)
  • Encryption = TKIP
I started by performing a scan, in order to find my wireless networks:


After the configuration, I had running on the wlan0 handle (with IP 192.168.1.7).


Selected in red the blinking green dongle's LEDs, that confirm that I had packets coming and going through the dongle:


Now I just wanted to confirm it that I had in fact the Wireless network configured. For that I used a double check-up:

- ipconfig on the SSH Shell:


- Router status (box in red):


Everything was in order. Only remained the final test, ie, to unplug the ethernet cable. I used the Midori browser to access my company's webpage, and it went smoothly:


Unfortunatelly this approach is not permanent. Every time I boot the Pi I have to set it up this way, which is not ideal. As I did on the previous post, I had to make this configuration permanent. For that I had to change the init.d network interfaces file.

In console, run the following command:

sudo nano /etc/network/interfaces
 
This is the original content of the interfaces file:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
 
If you want your router to assign an IP address automatically to your Pi, modify interfaces file to:
 
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid heimnetzwerk
wpa-psk 
# wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
# iface default inet dhcp
 
If you want to have a static IP address of your Pi, modify interfaces file to:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.XXX (insert suitable octet. I've chosen xxx= 199))
netmask 255.255.255.0
gateway 192.168.1.1 (change with appropriate gw)
wpa-ssid heimnetzwerk
wpa-psk 
# wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
# iface default inet dhcp
 
(Change 192.168.1.XXX to the IP you want to use)

Now, restart the network interface by issuing the following command:

sudo /etc/init.d/networking restart
 
Then, run ifconfig to check the result:

pi@raspberrypi ~ $ ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:38:da:d2
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1104 (1.0 KiB)  TX bytes:1104 (1.0 KiB)

wlan0     Link encap:Ethernet  HWaddr 24:3c:20:08:ee:17
          inet addr:192.168.1.7  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1444 errors:0 dropped:0 overruns:0 frame:0
          TX packets:283 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:345124 (337.0 KiB)  TX bytes:33694 (32.9 KiB)

pi@raspberrypi ~ $
 
Since I choose DHCP, so the IP address is 192.168.1.7.

When I rebooted the Pi, it connected to my network automatically.

Job done!

Happy hacking. You don’t learn to hack – you hack to learn...

MAAntão

2 comentários:

Anónimo disse...

Então a pen não fica logo activa após o boot, certo? Tenho de a "activar" pós boot...

Quando chegar a casa, depois do Real Manchester faço a assemblagem. Estás ligado depois do jogo?

Rui

Manuel Antão disse...

Certo.

Cria o SD Card com o Raspbian. Depois é seguir os passos do post.

Não estive ligado depois do jogo...