Make your Raspberrypi connect automatically to your wireless network
I bought a Raspberry Pi 3 this week and I want to share through this blog post something that made it easy for me to use my new device : Connecting to my router wireless SSID automatically even after a reboot. I am using Raspbian as a Raspberry Pi OS which is a Debian-based distribution, so configurations will not be very different if you used to work with Debian.
First thing to do is to plug the Raspberry Pi memory card to your Laptop, you can use a reader like the one I used first time:
Or you can also plug your Raspberry Pi to your local switch/router using a RJ45 ethernet cable. This will allow you to use ssh and gain access.
Anyway, using the card reader or plugging it to your local network will not change anything since in both cases, our goal is to add some configurations.
Now log in using SSH – Windows users use Putty:
The default password is “raspberry”
Open the network interfaces configuration file:
pi@raspberrypi:~ $ sudo vi /etc/network/interfaces
And add the following lines:
# The wifi (wireless) network interface auto wlan0 allow-hotplug wlan0 iface wlan0 inet dhcp wireless-essid YOUR_SSID wireless-key YOUR_SSID_PASSWORD
So that the entire file will be similar to the following one:
# interfaces(5) file used by ifup(8) and ifdown(8) # Please note that this file is written to be used with dhcpcd # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf' # Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d auto lo iface lo inet loopback iface eth0 inet manual # The wifi (wireless) network interface auto wlan0 allow-hotplug wlan0 iface wlan0 inet dhcp wireless-essid YOUR_SSID wireless-key YOUR_SSID_PASSWORD
Remove the ethernet cable and restart the network service, you will notice that you can still ping the raspberry.local host. Otherwise, reboot it and try again.
Happy Hacking !