tktbjp
Posts: 7
Joined: Mon Nov 03, 2014 2:58 am

Accessing Internet from Pi using USB Tethering of Android

Mon Nov 03, 2014 9:51 am

Hi,

I post this since it saved me a cost of buying a wifi-adapter and provided useful insight of pi-configuration.
I wanted to access internet from PI. There were 2-3 options.
1. Use Ethernet port.
Since I use wifi all the time, I do not have mechanism to connect my wifi router to LAN port. Although I guess it would have worked simply since I have LAN connector on router as well as on PI. But I had to buy another dataplan since router was dsl. But

2. Buy wifi-adapter and connect same to pi as mentioned in various articles.
Costly affair..

3. Use USB-tethering option of my smartphone.
I have Xperia-U and I use USB tethering option to connect my laptop to internet sometimes. This option I wanted to explore for connecting to internet. Then I could use same data plan everywhere.

So let me explain 3rd option.
On PI-B+ (which I purchased recently) have 4 USB ports. 2 are taken by keyboard and mouse already. One of the remaining can be used to connect to phone.
The default config file used by networking is /etc/network/interfaces works with wifi (wlan0) or eth(eth0) type of interfaces. It does not have entry for tethered device which android provides.

So we need to edit this file on Pi and add entries to it for usb (usb0).
#cat /etc/network/interfaces
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
#
The edit the file to provide hotplugging feature for usb0 type of interface which gets created when u start usb-tethering from android phone.
Add below entries at the end of /etc/network/interfaces file.
allow-hotplug usb0
iface usb0 inet dhcp

and then save the file.
You need to restart the board or networking using #sudo /etc/init.d/networking restart

Once this is done connect the phone to Pi using usb cable.
Enable data on android and wait till it activates and then enable USB tethering.

To see if the device is tethered, open a LXterminal session on pi and type #ifconfig
You should see interface usb0 is up and running with a valid IP assigned to it.

The open web-browser and it should be working fine.. :geek:

So you can use your android smartphones usb-tethring for connecting Pi to internet.. :geek:

Dijital
Posts: 20
Joined: Wed Nov 19, 2014 12:37 pm

Re: Accessing Internet from Pi using USB Tethering of Androi

Fri Nov 28, 2014 12:45 pm

You young man have just saved me about a four days worth of waiting :)

THANKS!

Monica3712
Posts: 1
Joined: Fri Feb 27, 2015 3:55 pm

Re: Accessing Internet from Pi using USB Tethering of Androi

Fri Feb 27, 2015 4:15 pm

Hi.I have interfaced the raspi(B+) to my laptop and followed your method .It is not working .Can you please let me know if I have to do some modifications or no.Thanks in advance.

tktbjp
Posts: 7
Joined: Mon Nov 03, 2014 2:58 am

Re: Accessing Internet from Pi using USB Tethering of Androi

Mon Mar 09, 2015 9:31 am

-
Last edited by tktbjp on Mon Mar 09, 2015 9:33 am, edited 1 time in total.

tktbjp
Posts: 7
Joined: Mon Nov 03, 2014 2:58 am

Re: Accessing Internet from Pi using USB Tethering of Androi

Mon Mar 09, 2015 9:32 am

Monica3712 wrote:Hi.I have interfaced the raspi(B+) to my laptop and followed your method .It is not working .Can you please let me know if I have to do some modifications or no.Thanks in advance.
The method I suggested was to interface usb-device to raspberry-pi B+.
I did not get when you say "Interfacsing with PC"? Can you please elaborate?

rt93
Posts: 1
Joined: Mon Mar 16, 2015 6:38 am

Re: Accessing Internet from Pi using USB Tethering of Androi

Mon Mar 16, 2015 6:42 am

Will this work on the laptop too??

sumo
Posts: 1
Joined: Sat Mar 14, 2015 4:32 pm

Re: Accessing Internet from Pi using USB Tethering of Androi

Sat Apr 18, 2015 1:19 pm

I have followed each step carefully as instructed.While pinging pi is sending the packets but it isn't receiving any.USB0 has been configured but I couldn't access any site. can anyone please help

Lark
Posts: 4
Joined: Thu Mar 05, 2015 2:34 pm

Re: Accessing Internet from Pi using USB Tethering of Androi

Sun Jun 28, 2015 11:32 am

I have tried to adjust the file interfaces/etc/network a few times (to apply tethering through my phone & tablet) but every time I try to save the file it returns an error message 'can't open file to write', what am I to do?

thanks in advance, NM
(just to clarify I am a complete newbie to all of this)

drgeoff
Posts: 8985
Joined: Wed Jan 25, 2012 6:39 pm

Re: Accessing Internet from Pi using USB Tethering of Androi

Sun Jun 28, 2015 12:15 pm

@Lark
Try

Code: Select all

sudo nano /etc/network/interfaces
If that works then Google sudo.

Lark
Posts: 4
Joined: Thu Mar 05, 2015 2:34 pm

Re: Accessing Internet from Pi using USB Tethering of Androi

Wed Jul 01, 2015 12:28 pm

@drgeoff thanks that's sort of worked, I now have three new (interfaces.save/1/2) files but I still can't edit them as all permission is set to root
still reading into sudo
Lark

centurion555
Posts: 1
Joined: Thu Apr 28, 2016 8:40 am

Re: Accessing Internet from Pi using USB Tethering of Androi

Thu Apr 28, 2016 8:45 am

Thanks, the above instructions work for me. But every time, I connect an android phone, I have to restart otherweise there is no internet. My problem is I am using pi for some automated jobs and it is running without monitor and keyboard so I can't restart it or restart networking every time I connect the smartphone for internet. Is it possible to make it fully automated.... I just connect my phone and turns on usb thethering on the phone and it works without any furthur steps..... Thanks in advance

User avatar
Redryno
Posts: 8
Joined: Tue Jun 28, 2016 12:31 am
Location: Missouri, USA

Re: Accessing Internet from Pi using USB Tethering of Androi

Thu Jul 07, 2016 1:45 pm

I had an issue setting this up and have spent the last few days trying to figure it out. There is a lot of information on several forums but i couldn't find a solution to this problem.

Problem: when i set the tablet to tether i ran "dmesg" in the console and it would come back "can't set config #1, error -110". When i ran "ifconfig" usb0 wouldn't show up at all.

Solution: on the tablet under "Developer tools" (how to unlock tools http://bit.ly/29kTttE) i turned on "usb debug". Steps to connect are: plug in usb, turn on usb debugging then turn on usb tether. Reverse to disconnect.

I'm using x11vnc on Rpi port 0 (so i see the desktop), Real VNC on the Android tablet. In the /etc/network/interfaces i used static (so i know the ip address when connecting)

Code: Select all

iface usb0 inet static
    address 192.168.42.42
    netmask 255.255.255.0
P.S. if i am using just the tablet as my screen i can't see a usb mouse that is plugged into the Rpi move on the VNC viewer, but i can see anything typed on a usb keyboard (not a fan of the Android software keyboard, drag and tap mouse is okay).

NuclearFusion
Posts: 16
Joined: Thu Jul 07, 2016 10:04 pm

Re: Accessing Internet from Pi using USB Tethering of Androi

Tue Jul 19, 2016 6:46 am

Hello. Was just wondering if it would be possible to do the exact opposite, as in using the pi to give wifi access to my android phone via usb tethering. If it is possible how would I do it? Thanks for any info.

fruitoftheloom
Posts: 18556
Joined: Tue Mar 25, 2014 12:40 pm

Re: Accessing Internet from Pi using USB Tethering of Androi

Tue Jul 19, 2016 7:21 am

NuclearFusion wrote:Hello. Was just wondering if it would be possible to do the exact opposite, as in using the pi to give wifi access to my android phone via usb tethering. If it is possible how would I do it? Thanks for any info.
It is "USB Reverse Tethering" though most Android Devices require Root Access, but there is an App which I personally have not tried:

https://play.google.com/store/apps/deta ... ering.free

Lots of hits on Google as well..
adieu

My other Computer is an Asus CS10 ChromeBit

clem--22
Posts: 1
Joined: Sun Nov 06, 2016 12:39 pm

Re: Accessing Internet from Pi using USB Tethering of Androi

Sun Nov 06, 2016 1:35 pm

Hi,

Thank you tktbjp for your topic. I would like to use your methode to replace my "poor cable home connection" ^^. However, I've a problem (I've run traceroute to diagnose the problem) :

- My phone in Tethering connection is good detected by the Rpi but I can't go on Internet from Rpi
- It's work when I use my Wifi connection from phone to my cable home connection.
- From my phone, I can go on Web with 4G

So the problem come from the 4G interface of my phone. Someone have an idea how to fix that ?

Thanks in advance :)

nahueltaibo
Posts: 1
Joined: Tue Mar 28, 2017 7:44 pm

Re: Accessing Internet from Pi using USB Tethering of Androi

Tue Mar 28, 2017 7:48 pm

This worked perfectly on my RPi 2.
Nevertheless, I tried to make it work on my Rpi Zero W without success, I think it might be because I'm using an OTG cable to be able to connect both micro USB connectors in the RpiZeroW and in the Android phone.

The Android phone does not recognize the RpiZero as connected, hence, the USB tethering is grayed out.

Any idea on how can I solve this?

I tried with the USB OTG cable on both ends (Rpi and Android) without success on either case

TimJSamuels
Posts: 1
Joined: Fri May 19, 2017 1:18 pm

Re: Accessing Internet from Pi using USB Tethering of Androi

Fri May 19, 2017 1:37 pm

Just a simple comment, I typed it out in nano as it was blank than saved it after deleting the "ect/network/" part ctlO then ctlR.
I'm a newbie but thorough it might help.

donde123
Posts: 14
Joined: Wed Apr 12, 2017 7:16 pm

Re: Accessing Internet from Pi using USB Tethering of Androi

Fri May 26, 2017 2:31 am

Type this:
sudo nano /etc/network/interfaces

It will bring up the file you need to edit.

Add what you want to the bottom of file.

Then save file this way:

Hold Ctrl key down and hit o not zero
Release Ctrl key and hit Enter
Hold Ctrl key down and hit x

The file is now saved with the added info.

User avatar
sathishdorai
Posts: 1
Joined: Thu Sep 14, 2017 6:44 am

Re: Accessing Internet from Pi using USB Tethering of Android

Sun Apr 08, 2018 4:56 pm

Hi tktbjp
Could you make one same detailed description for hooking on a USB modem to RPi...?

dipen
Posts: 12
Joined: Wed Aug 03, 2016 6:41 am

Re: Accessing Internet from Pi using USB Tethering of Android

Fri Oct 26, 2018 2:46 pm

Namaste tktbjp,

This post of yours helped me in achieving USB Tethering on RPi 3 Model B+ using a mobile phone. I could browse thorough the internet via USB Tethering.

Many thanks for this post of yours!
Thanks | Regards,
Dipen

Return to “Advanced users”