Blog available for sell
This blog is available for sale. Please 'contact us' if interested.
Advertise with us
wifi ssh raspberrypi   0   16882
Programming on Raspberry Pi with Python: WIFI and SSH configuration

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.

Configure WIFI:

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

- 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 your country code. For example, for India, it will be IN.

Enabling SSH:

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.



hostname -I


Now you can SSH into Raspberry Pi using the command ssh pi@ and default password.

In the next article, we will create a python script which will run when Raspberry Pi starts and sends the IP address to you on Telegram channel so that you can SSH into it without the help of external monitor or LAN cable.



Purchase Raspberry Pi Starter Kit Here.

Featured image source: 

wifi ssh raspberrypi   0   16882
0 comments on 'Programming On Raspberry Pi With Python: Wifi And Ssh Configuration'
Login to comment

Related Articles:
Programming on Raspberry Pi with Python: Controlling LED
Starting with Raspberry Pi programming with Python, Controlling LED with Python Program, Blinking LED with Raspberry Pi, Using GPIO pins to control the LED on Raspberry Pi with Python Program, Raspberry Pi and python...
Programming on Raspberry Pi with Python: Sending IP address on Telegram channel on Raspberry Pi reboot
How to setup Raspberry Pi, Starting with Raspberry Pi programming with Python, Sending IP address to Telegram channel on Raspberry Pi Boot up, SSH using Raspberry Pi, Raspberry Pi and python...
DigitalOcean Referral Badge

© 2022-2023 Python Circle   Contact   Sponsor   Archive   Sitemap