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:
1 |
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf |
Go to the bottom of the file and add the following:
1 2 3 4 5 6 7 8 9 |
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=IE network={ ssid="pihome" //Your Wifi SSID psk="myPiHome123456" //Your Wifi's Key/passphrase key_mgmt=WPA-PSK } |
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
1 2 3 4 5 6 7 8 9 |
auto lo iface lo inet loopback iface eth0 inet dhcp allow-hotplug wlan0 auto wlan0 iface wlan0 inet static address 192.168.1.10 netmask 255.255.255.0 gateway 192.168.0.1 |
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.
1 2 3 4 |
sudo nano /etc/hostname sudo reboot hostname --fqd sudo apt-get update |
6 comments
First and foremost thanks for the instructions – it works beautifully. However, some time raspberry pi loses connection to wifi. Any tips? I am new to RPi, so apologies if it’s very obvious.
Thanks
Valerio
@Valerio have look at http://www.pihome.eu/2017/10/19/auto-reconnecting-wifi-on-raspberry/ for reconnect wifi if for any reason it get disconnected.
I have raspberry pi zero and I was wondering how I can do pre-configuration specially wifi settings and enable ssh as I don’t have all cables for my pi zero. this is as simple as it can get 🙂
Hi James,
have look here, http://www.pihome.eu/2017/10/11/os-raspbian-jessie-installation-wifi/ for setup wifi and enable ssh after burning image to sd card,
Admin
Hello. I have loaded your img successfully but now I am having trouble setting up a static IP for eth0.
I edited /etc/dhcpcd.conf with
interface eth0
static ip_address=192.168.0.200/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
And it worked but then the system becomes painfully slow, like 10 seconds each command I send.
if I remove those lines, it becomes fast again but I get an IP that is not 192.168.0.200.
This didn’t happen in strech from NOOBs it is only happening with your img file of 1700Mb:
http://www.pihome.eu/2018/03/25/download-lamp-apache-php-7-0-and-mysql-mariadb-and-phpmyadmin-server-img-file/#comment-412
What do you think is happening?
Hi Copito,
yes you need to modify /etc/dhcpcd.conf which you already did, now try to run top and see what is using your cpu/ram ?