An advantage with the RaspberryPi’s is being able to have it run over WiFi, cutting down the number of wires going to it. This makes running it headless a lot easier since it only needs a power cable then. I got a USB WiFi module form adafruit which can be found here. I am also going to be giving it a static IP address like I did in my previous post and I will be giving it the same one also since I will be either using the Ethernet cable or the WiFi module.
I did this with the Ethernet cable plugged in and the USB WiFi module not plugged in.
I’ll start with editing the same file as in the last post.
pi@raspberrypi ~ $ sudo nano /etc/network/interfaces |
Scroll down to the last line and add the following lines:
iface home inet static address 192.168.1.115 netmask 255.255.255.0 gateway 192.168.1.1 iface default inet dhcp |
Again, the address line is the IP address I am assigning to the RaspberryPi on WiFi and the other lines I got from the router.
Save and exit the editor with:
Ctrl+X Y Enter |
There is another file that you have to edit with the network information, wpa_supplicant.conf
pi@raspberrypi ~ $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf |
Scroll to the end of the document (There should only be 1-2 lines in there.) and add the following:
network={ ssid=____ key_mgmt=NONE auth_alg=OPEN wep_key0=____ id_str=”home” } |
ssid is the network name and wep_key0 (That is a zero after key!) is the password with wep encryption.
Save and exit the editor and you should be all set.
I turned off my Pi with:
pi@raspberrypi ~ $ sudo halt |
and once it powered down I removed the power cord and Ethernet cable, plygged in the USB WiFi module, and plugged back in the power cord.
I tested my connection with
pi@raspberrypi ~ $ ifconfig |
and saw that I was connected! I am now one cable lighter on my RaspberryPi!
See you next time,
WeekendEngineer