raspberry-pi wifi ssh   0   79
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 dicussed, 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 Raspberry Pi 3 B+ model.


Configure WIFI:

We need to update the WIFI settings to that everytime 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 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 

Update your country code. For example for India it will be IN.


Enabling SSH:

You can enable SSH using one of the method below. Try and see which one works for you.

Method 1:

 - Open the Raspberry Pi configurations using 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 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 Rasperry Pi, use below commands.

ifconfig

VG4O4FbhRl0J+uAwLRsZBVHQNurYvbqLQ1mtHaVAQCgUB0NdB6HQQCgUAgEF0Z5OsgEAgEAoHoyqA5LAQCgUAgEF0ZFNdBIBAIBALRlUG+DgKBQCAQiK4M8nUQCAQCgUB0ZZCvg0AgEAgEoiuDfB0EAoFAIBBdGeTrIBAIBAKB6MogXweBQCAQCERXBvk6CAQCgUAgujLI10EgEAgEAtGVQb4OAoFAIBCIrgzydRAIBAKBQHRlkK+DQCAQCASiK4N8HQQCgUAgEF0Z5OsgEAgEAoHoyiBfB4FAIBAIRFcG+ToIBAKBQCC6MsjXQSAQCAQC0ZVBvg4CgUAgEIiuDPJ1EAgEAoFAdGWIf7oCiD8MjUnnkzqaqvyv1QSBQCAQiM4AxXUQCAQCgUB0ZVrj60iR5sT3WBEvMXkirtPq01VAWiEQCAQC8XfwfxOUtB3WDgIhAAAAAElFTkSuQmCC


hostname -I

VcQhj0jFKDF9gWgb13RElSFSMRie5wkR0z6KiIhUARx16JKiXhQRERGR8sNQCkLtFopDm4j78oiIiFQMhgHEIY+IiEiVwJDH1uKKiIiIVAyGEEJQdpYlERERkTLh7AH3oj4RERGpPPYhD0SVIiIiUnn+DyiygX9bv1z2AAAAAElFTkSuQmCC


Now you can SSH into Raspberry Pi using command ssh pi@192.168.0.4 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.


References:

 - 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.


Featured image source: https://howtoraspberrypi.com/ 

raspberry-pi wifi ssh   0   79

Related Articles:
Programming on Raspberry Pi with Python: Raspberry Pi Setup
How to setup Raspberry Pi. Installing Raspbian on Raspberry Pi 3 B+ model and configure settings. Starting with Raspberry Pi programming with 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...
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...
Programming On Raspberry Pi With Python: Activate LED and Buzzer on Motion Detection
Turn on LED and activate the buzzer when motion is detected using PIR Motion detection sensor. Using PIR motion detection sensor along with buzzer with Raspberry PI. Python Program to detect motion and activating the alarm system using Raspberry Pi....

0 thoughts on 'Programming On Raspberry Pi With Python: Wifi And Ssh Configuration'
Leave a comment:


*All Fields are mandatory. **Email Id will not be published publicly.


SUBSCRIBE
Please subscribe to get the latest articles in your mailbox.



Recent Posts:






© pythoncircle.com 2018-2019