In my previous post I’ve explained the method of connecting Raspberry PI with Laptop through Ethernet.
https://alselectro.wordpress.com/2017/02/17/raspberry-pi-3-how-to-connect-with-your-laptop/
At times , the PI is not recognized , or unable to contact over SSH in this method.
Let us see the DIRECT NETWORK LINK method In this post which is 100% reliable.Cons is that network internet is not shared.But this is not an issue , as PI3 is WIFI capable through which you can connect to internet.
To start with , place the SD card ( class 10 type recommended ) with Raspbian OS on to a Card Reader
The card will be shown as boot drive.Open it.
Under View , un tick the option “ File Name Extension”
Now Right click on empty space & create a new text document.
Rename it to ssh & save it.
Now a file named ssh is created without any file extension
When the card is now used on RPI, on first boot the OS will look out for the ssh file name.If it finds one , it enables secure shell & then delete the file named ssh.
This is how SSH is enabled in a Headless mode operation of RPI.
Place the SD card on to PI & power it up.
Now Open Network& Sharing center on your Windows PC.
Connect the Ethernet port of RPI to the Ethernet port of your PC using a STRAIGHT RJ45 Cable.
An Unidentified Network is created for the Ethernet adapter where PI is connected .
Click on the Network connection type ,( here mine is WIFI.)
Click properties
Under SHARING Tab un tick the options so that Network sharing is DISABLED.
Click on the ETHERNET connection & then Properties on next window.
Double click Internet Protocol 4 & ensure that DHCP is enabled i.e, Obtain IP address automatically is selected.
For a network link to work between two computers they need to be using the same address range.
The allowable address range is determined by the subnet mask.
255.255.0.0 means all octets in addresses should be same except for the last two in the IP address,otherwise they will be filtered.
Most PCs connected directly to another computer will allocate an IP address in the range 169.254.x.x ( with subnet mask of 255.255.0.0)
For RPI to be able to communicate through the direct link it needs to have a fixed IP address in the same address range 169.254.x.x
We can set this in the cmdline.txt file
To know the IP allotted to the ETHERNET adapter
Open Command Prompt ,CMD
Type in ipconfig /all
Scroll down to find the IP under Ethernet adapter.
Here it is 169.254.192.43
which is the Gateway IP of Ethernet adapter.Any device connected to this port should have the IP in range 169.254.192.x
As we’ve connected the PI to Ethernet adapter let us assign the IP toPI as
169.254.192.150
Note that the last octet can be anything up to 255.
The static IP to PI is assigned as follows :
Switch off power to PI ,remove SD card & place it on a card reader.
Open cmdline file found in the SD card
Move to the End of file.
Please note that you must not hit Enter .
Just at the end type in
ip=169.254.192.150
Save the file .Remove SD card from card reader & plug it to PI & power it up.
Let us use the free SSH Client PUTTY to log intoPI.
Open PUTTY & under Session , type in the IP address 169.254.192.150
Ensure that SSH is selected.
Click open
Now you get the LOG IN window of PI
login as pi & password : raspberry
Now ,let us see how to log in Graphical user interface.
For this a XMING X Server is required.
Download XMING from here
Install XMING & start the server.
Open Putty & as done previously enter the IP address 169.254.192.150
Under SSH click X11
& then Tick mark Enable X11 forwarding.
Click Open to get the login window of PI.
To get Graphical interface , type in
startlxde
Now you get the graphical screen
To get internet access :
Under SYSTEM TOOLS click LXTerminal
Type in
sudo raspi-config
Select Network Options
Select WI FI
Then enter SSID of your WIFI to connect with
Provide the password for thee SSID
Hit FINISH
Now you get the internet accesswhich can be tested by
sudo apt-get update.
VIDEO DEMO :
getting error on ‘sudo apt-get update’ command like Cannot initiate the connection to raspbian.raspberrypi.org:80 (2a00:1098:0:80:1000:75:0:3). – connect (101: Network is unreachable) [IP: 2a00:1098:0:80:1000:75:0:3 80]