In the first article of this series, we worked on setting up the Raspberry Pi. Also as discussed, we were connected to Pi using LAN cable which reduces the mobility of Raspberry Pi.
Programming on Raspberry Pi with Python: Raspberry Pi Setup
In this article, we will configure WIFI settings so that we can access the Raspberry Pi over SSH from our laptop.
We are using the Raspberry Pi 3 B+ model.
We need to update the WIFI settings to that every time Raspberry Pi is booted, it connects to the available WIFI network automatically.
- Login to your account on Raspberry Pi. If you haven't changed the password, default username and password is available in the previous post.
- Now open the file /etc/network/interfaces
in nano editor. We need to edit it, open it with root permissions. Use below command.
sudo nano /etc/network/interfaces
- Add below lines in the file.
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "WIFI NETWORK NAME HERE"
wpa-psk "WIFI NETWORK PASSWORD HERE"
- Update the localization settings to set the WIFI country. Open the file /etc/wpa_supplicant/wpa_supplicant.conf
and make below entries in it.
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=YOUR COUNTRY CODE HERE
IN
.You can enable SSH using one of the methods below. Try and see which one works for you.
Method 1:
- Open the Raspberry Pi configurations using the command sudo raspi-config
.
- Select Interfacing Option and then SSH.
- Enable SSH. Save and Exit.
Method 2:
- Create a file name ssh without extension in /boot
partition of Raspberry Pi.
Method 3:
- Use below commands to enable and start the SSH.
sudo systemctl enable ssh
sudo systemctl start ssh
So now we have WIFI configured and SSH enabled. That means next time when Raspberry Pi boots up it will connect to available WIFI network and you can SSH into it. You will not require a LAN cable to connect to it anymore. But....
How do you know the IP address of your Pi after it restarts?
To know the IP address after you are logged in into Raspberry Pi, use below commands.
ifconfig
hostname -I
ssh pi@192.168.0.4
and default password. - https://raspberrypi.stackexchange.com/questions/30144/connect-raspberry-pi-to-pc-ubuntu-with-ethernet
- https://www.raspberrypi.org/documentation/remote-access/ssh/
- https://askubuntu.com/questions/996963/connecting-pc-and-raspberrypi-using-lan-cable
- https://maker.pro/raspberry-pi/tutorial/how-to-connect-a-raspberry-pi-to-a-laptop-display
Purchase Raspberry Pi Starter Kit Here.