I prefer to use WiFi on Raspberry Pi as it makes RPi portable and limits the numbers of cable attached to this small mighty computer lets do Raspberry Pi WiFi setup to have less cables attached to this might computer.

Setup WiFi on Raspberry Pi

Lets setup wifi on raspberry pi so we can go wireless, First you need to scan for wifi networks, use the command sudo iwlist scanning wlan0 scan to list all available wifi networks in your range, along with other useful information. Now we need to add wifi configuration and save it to go wireless.

Edit WiFi config file:

Go to the bottom of the file and add the following:

Now you can reboot your raspberry pi with sudo reboot and disconnect any Ethernet cable if you have it connected to test WiFi connection, once raspberry pi rebooted successfully you can ping your gateway.
Setting up a static IP address

If you want your raspberry pi to always have the same ip address then you need to change interfaces file to a static IP address. To edit your interfaces file: sudo nano /etc/network/interfaces

Make sure you know your LAN ip range, 192.168.1.x is very common.

Change Pi Hostname

Lets change hostname of your Raspberry Pi, this step is important otherwise you’ll end up with lots and lots of error message in your logs hence higher usage of your SD card.