Solved

how to use internet from wifi router for raspberry pi

Posted on 2016-07-15
22
92 Views
Last Modified: 2016-08-13
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
0
Comment
Question by:Soumen Roy
  • 12
  • 6
  • 4
22 Comments
 
LVL 38

Assisted Solution

by:Tom Beck
Tom Beck earned 250 total points
Comment Utility
Have a look at this article. It speaks of using a WiFi dongle but it should work with the built in wifi.

The important part in the interfaces file is the dhcp

allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp


For the /etc/wpa_supplicant/wpa_supplicant.conf file, you can add multiple wifi networks like:

network {
...
...
}

network {
...
...
}
1
 
LVL 7

Expert Comment

by:Fouad Maidine
Comment Utility
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

0
 

Author Comment

by:Soumen Roy
Comment Utility
@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
0
 

Author Comment

by:Soumen Roy
Comment Utility
@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
0
 
LVL 38

Expert Comment

by:Tom Beck
Comment Utility
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.
0
 
LVL 7

Expert Comment

by:Fouad Maidine
Comment Utility
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
0
 
LVL 7

Expert Comment

by:Fouad Maidine
Comment Utility
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.
0
 

Author Comment

by:Soumen Roy
Comment Utility
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
0
 

Author Comment

by:Soumen Roy
Comment Utility
@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

Screen Shot of "sudo apt-get update" error
0
 
LVL 38

Expert Comment

by:Tom Beck
Comment Utility
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.
0
 

Author Comment

by:Soumen Roy
Comment Utility
@Tom Beck:

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

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

Regards,
Soumen
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Soumen Roy
Comment Utility
@Tom Beck:

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

Regards,
Soumen
0
 

Author Comment

by:Soumen Roy
Comment Utility
@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
0
 
LVL 7

Expert Comment

by:Fouad Maidine
Comment Utility
@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
0
 
LVL 38

Expert Comment

by:Tom Beck
Comment Utility
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.
0
 

Author Comment

by:Soumen Roy
Comment Utility
@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
0
 
LVL 7

Expert Comment

by:Fouad Maidine
Comment Utility
@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 !
0
 

Author Comment

by:Soumen Roy
Comment Utility
@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.
1.png
Regards,
Soumen
0
 

Author Comment

by:Soumen Roy
Comment Utility
@Tom Beck and @Fouad Maidine:

For your reference I am attaching my WiFi Properties of Win10 Laptop here:
1.png
And here are my LAN Properties of Win10 Laptop here:
2.PNG
Here are my WiFi Router Properties from my Laptop:
3.PNG
Regards,
Soumen
3.PNG
0
 
LVL 7

Accepted Solution

by:
Fouad Maidine earned 250 total points
Comment Utility
well it does have wireless !

If you want to enable Wireless :

You can follow this tutorial to use your wireless WIFI on raspbery pi :

https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

make sure to use the ssid and password of your wifi of course :-D
1
 

Author Comment

by:Soumen Roy
Comment Utility
@Fouad Maidine:

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

Untitled.png
That link you shared, did it. Thanks a lot :-).

Regards,
Soumen
0
 

Author Closing Comment

by:Soumen Roy
Comment Utility
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
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Virtual CD burner 19 69
Exam question 48 97
Rubber hose 5 44
Noisy or bad lifters 7 23
Surprisingly, there is a lot to Gym battles, and I thought it would be helpful to share knowledge about all the ins and outs of this feature!
This story has been written with permission from the scammed victim, a valued client of mine – identity protected by request.
This video teaches viewers how to process images for a time-lapse video. Programs required: Adobe Lightroom, Adobe After Effects, Video Editing Program. In Adobe Lightroom: Import sequence image files into Adobe Lightroom: Develop settings of an I…
The Bounty Board allows you to request an article or video on any technical topic, or fulfill a bounty request to earn points. Watch this video to learn how to use the Bounty Board to get the content you want, earn points, and browse submitted bount…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now