Link to home
Start Free TrialLog in
Avatar of Soumen Roy
Soumen RoyFlag for India

asked on

how to use internet from wifi router for raspberry pi

hi,

i am very novice in raspberry pi.

i purchased a raspberry (screen shot attached here) pi 3. i installed raspbian there. i can connect that with my laptop (headless installation). for that i opened command.txt and put an extra parameter as "ip=192.168.3.14". until this it worked as through PuTTY i can connect.

problem occurs after this. i needs to use "sudo apt-get update". but without internet in raspderry i can not update. i have an wifi router. how can i use that internet access in raspberry pi? or is there any way to use my laptop internet to raspberry?

i am using windows 10 in my laptop through which i connected raspberry.

regards,
soumen
raspberry_pi_3.jpg
SOLUTION
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you just need to upgrade it you can :

Download the packages required for the update

put them in a folder in a sd card and run :

cd that_folder_with_debian_packages
sudo dpkg -i *.deb

Open in new window

Avatar of Soumen Roy

ASKER

@Tom Beck:

Just now I am going through the link you provided. Thanks for the link. I am very much novice in this area. I could not understand the rest of the comments from you actually :D. I have no idea what "interfaces file is the dhcp" means.

@Fouad Maidine:

I have created microsd with raspbian OS as I said previously. Till now I can only ping to my raspberry pi. nothing else. From internet, I came to know next step is to update software. But for updation, I need internet connection in my RPi. Thats where I am getting stuck. I connected that RPi with my Laptop (Win 10) i.e. no display / mouse / keyboard is attached with my RPi. now if I can not get internet in my RPi, I can not update the Software in RPi. That's my problem is now. You suggested

1. Download the packages required for the update.
2. put them in a folder in a sd card and run:
                        cd that_folder_with_debian_packages
                         sudo dpkg -i *.deb

But I already downloaded raspbian and installed that in my Micro SD. Please suggest I need to create Debian instead of Raspbian? I am not clear. Please suggest.

Regards,
Soumen
@Tom Beck:

In continuation of my comment, I am now trying to attach my WiFi dongle as directed in your suggested article. Can I activate in built WiFi receiver of my RPi 3? Is there any way to do that?

Regards,
Soumen
Don't bother with the wifi dongle until you are into the RPi terminal and can configure it.

In your original question you said "until this it worked as through PuTTY i can connect." By that I understood that you could already SSH into the Raspberry through PuTTY.

You say "i am using windows 10 in my laptop through which i connected raspberry."

How is the laptop connected to the RPi? A direct ethernet connection will not work unless you have a cross-over cable.

The latest Raspbian OS images (like Raspbian Jessie) have SSH enabled by default so PuTTY should work.

If you plug the RPi into your wifi router by ethernet cable it will be given an IP address. Your original question mentions 192.168.3.14 so I assume you already know the IP address of the RPi. Use that address in PuTTY from the laptop. Use pi as the username and raspberry as the password to unlock the terminal of the RPi. Once logged into the RPi terminal you can run update and configure the wifi dongle. If you have a Raspberry Pi 3 Model B, wifi is built in. You don't need the dongle.
Im suggesting to update your Raspbian (wich is a free operating system based on Debian )
you need to find out which .deb file you need, and transfer those to your Raspberry Pi, and place them in a folder ( with any name you want) and run

sudo dpkg -i /example/xyz

where xyz is the exact name of the .deb file you want to install

It seems you are following a guide , do you need to fully update the raspbian or do you just need to install Some specific software to do something specific ?

Keep in mind This sugestion is just a work around in case the wifi does not work
Because if lets say i need nano file text editor for example , on raspbian i would :

 sudo apt-get install nano

Using this command on an raspbian without connection would show  an error , 'with "failed to fetch ..." and the http link of the package ,thus allowing you to download that deb package and install it Offline on your device.
Thank you @Tom Beck and @Fouad Maidine for your guidance.

====================================================================================
@Tom Beck:

Yes, you have correctly understood my problem.

 What I can do until now
-----------------------------------

I can remotely login to my RPi with PuTTY from my Win10 Laptop. I edited the cmdline.txt. The content is as follows:

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait ip=169.254.3.14

Now, I can open PuTTy and give the IP as 169.254.3.14 and can login with uid=pi and pwd=raspberry.

 What my problem is
------------------------------

From internet I understood that I need to give following command now, after login:
sudo apt-get update

But, as I can not have any internet connection in RPi, this command does not work. I need to get internet from my WiFi router in the RPi.

What was my Idea previously
-------------------------------------------
To get internet in RPi, I need to attach WiFi dongle with my RPi. So I have followed the way you suggested in the link and modified accordingly. But I don't know how to get internet in my router. Just in your last comment, I am getting an idea that RPi has it's in-built WiFi. Now if I can access internet with that, my problem to issue "sudo apt-get update" command will be solved. But I don't know "How to activate that? How can I utilise that to access internet?"

Please help.

Regards,
Soumen

=================================================================================

@Fouad Maidine:

My main problem is, how to connect internet from RPi. Probably, I could not make my problem clear in my previous messages. Sorry for my bad english.

Regards,
Soumen
@Fouad Maidine:

sudo apt-get install nano
command worked. But when I tried

sudo apt-get update
I got error. The screen shot is attached here

User generated image
Here's the part I don't understand. You have PuTTY working. How are you connected? Do you have the RPi connected directly to the laptop? Or do you have the RPi connected by ethernet to the router so it's on the same network? The last way is the way you should do it so the RPi gets internet from the router. If the RPi does not automatically get an IP address from the router than the next step is to edit the interfaces file using nano to turn on dhcp.

Nano is a file editing program you use from terminal. No need to install it. Raspbian has it built-in. When you want to create or edit an existing file on the RPi from terminal you just type sudo nano </path/filename.ext>. If the file exists at the path you specify, it will open for editing. If it doesn't exist, it will allow you to create a new file at that location.

The instructions I gave you at the link suggest that you edit two files using nano. The interfaces file is edited to turn on dhcp (to automatically obtain IP address leases from the dhcp server or router). The wpa_supplicant.conf file is where you can manually add wifi networks.
@Tom Beck:

For your information, how I am trying to connect is as follows:

I checked my RPi ip as follows:
User generated image
Then I shared my WiFi internet through LAN as follows:
User generated image
Then I ping as "ping raspberrypi.mshome.net" to check my raspeberry ip and getting the following screen:
User generated image
Then I opened PuTTy and give that ip as follows:
User generated image
Then I login to RPi successfully. Then issued following command:
"sudo apt-get update"
I am getting the following error as shown in screenshot
User generated image
Hope I am clear where I am getting stuck.

Regards,
Soumen
@Tom Beck:

For your information, my LAN Cable is attached with my Win10 Laptop and RPi

Regards,
Soumen
@Tom Beck:

For your information, I have a WiFi router and my Laptop is getting internet through that WiFi. Now I want to get internet in my RPi as well for which I am trying.

Regards,
Soumen
@Soumen Roy

There was no need to run that command it was just an example ^^.

and now i do understand your problems the screenshots make it super clear

You router running dhcp and your raspbery seems to have static ip adress ?

You can either enable DHCP on raspberi pi to fix this ?

 or set up static ip adress and disable DHCP.

Check the status of your eth interface first , lets us know what you have there ( take a screen shot )

run ifconfig

run netstat -nr

Take screen shots and give us those we will guide you

@Tom :

"A direct ethernet connection will not work unless you have a cross-over cable"

 the Raspberry Pi LAN chip  reconfigures itself for direct network connections no need for that
What you have done seems reasonable but I have never tried it that way. I suspect the problem is DNS.

Question #1:  The laptop is getting internet from the router which has assigned IP 192.168.0.103 with a DNS server of 172.16.0.1. If the laptop is supposed to be sharing its internet, why is it assigning an IP to the RPi in a different subnet (192.168.137.199)? Maybe that's the way internet sharing works on a Windows laptop. I have no experience with that. Maybe the laptop acts as a router and creates a new network. That's fine and it will work as long as the laptop routes DNS requests properly back to the 192.168.0.x network.  My guess is that either it's not doing that properly or the RPi has static name server entries that are in conflict with this set up. You can open resolv.config on the RPi to see the listed name servers if there are any.

Question #2:  Why are you doing this the hard way? Plug the RPi into the router so it's on the same network as the laptop.
@Tom Beck:

Regarding Question #1:

I really do not have any idea. I found a tutorial in YouTube at
"https://www.youtube.com/watch?v=lsvDMztXi4o". I am blindly following that and trying to connect RPi. :-).

Regarding Question #2:

"Plug the RPi into the router ..." that's seems interesting. But how to plug in RPi with WiFi router? I access internet from my WiFi router to my laptop, desktop, mobiles and tabs in my home. But how to use that internet in RPi? I don't know, really. Thats where I am stuck.

Regards,
Soumen
@Soumen

Thats a good tutorial (but you cant use the same ip adress int he video since its not the same network) But for now to fix your issue :

Change the IP in the cmdline.txt to some IP that is in range of the network ( say 192.168.0.50 for example) Either this or Manually change it in the Raspbery PI.

Because it wont work even if you plug in the router with this Ip adress .

Save Reboot the raspbery and test

also :

run ifconfig

run netstat -nr

and give us screen shots , the (if config command) will also show us if your raspbery pi has A Wireless interface or not so you could use Tom Beck suggestion !
@Fouad Maidine:

I am attaching cmdline.txt for your reference here.
cmdline.txt

I am attaching ifconfig and netstat -nr result here for your reference also as advised.
User generated image
Regards,
Soumen
@Tom Beck and @Fouad Maidine:

For your reference I am attaching my WiFi Properties of Win10 Laptop here:
User generated image
And here are my LAN Properties of Win10 Laptop here:
User generated image
Here are my WiFi Router Properties from my Laptop:
User generated image
Regards,
Soumen
3.PNG
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Fouad Maidine:

At last, it is done :-). Finally
sudo apt-get update
works and got internet from WiFi.

User generated image
That link you shared, did it. Thanks a lot :-).

Regards,
Soumen
Thanks for both of you. Actually @Tom Beck initially suggested the right thing, but I was not understanding his solution. Link from @Fouad Maidine actually resolved my problem. Thank you very much. Thank you a lot to both of you.

Regards,
Soumen