rcw
Posts: 2
Joined: Tue Oct 02, 2012 7:12 am

Huawei E3131 on Wheezy

Tue Oct 02, 2012 8:11 am

I've managed to get a Huawei E3131 3G dongle working on the Pi and thought some might like the benefit of my experiences:

Firstly, beware that the device can take more power than the Pi's USB port can deliver and so should always be attached via an external powered hub.

When first plugged in, the E3131 presents as a CD drive with USB id 12d1:1f01 and "udev" will typically assign it the first optical disc id: "/dev/sr0". The device can be mounted read-only to inspect the installation software. Use the command "lsusb" to display the USB id.

To make the device useful, it must be switched from CD mode into Network mode. Switching can be achieved by sending the device a USB SCSI command using the utility "sg_raw" which is a part of the "sg3-utils" package. To install it, enter the command "apt-get install sg3-utils".

The command to perform the mode switch is:

Code: Select all

/usr/bin/sg_raw /dev/sr0 11 06 20 00 00 00 00 00 01 00
When in network mode, the device will present as a cdc_ether USB network controller with USB id 12d1:14db. The driver will load automatically and a new network interface "eth1" can be seen on entering the command "ifconfig -a".

The E3131 is now available at one end of a point-to-point network having a default IP address of 192.168.1.1/24. To connect to it, we must configure "eth1" to have an address on that same network.

Beware that 192.168.1.* is a very commonly used network which may already be in use on your wired Ethernet. If so, you will need to disconnect the network lead before continuing.

The command to configure the network interface is:

Code: Select all

ifconfig eth1 192.168.123.100
If all goes well, you can now test the link using the command:

Code: Select all

ping 192.168.1.1
Any response will be from the Huawei dongle.

It's possible to automate the whole procedure; we need to automatically switch from storage device to network mode and to automatically assign an IP address. This can be done by editing 2 files:

To automate the mode switch, create a new file "/etc/udev/rules.d/10-HuaweiFlashCard.rules" with the following content:

Code: Select all

SUBSYSTEMS=="usb", ATTRS{modalias}=="usb:v12D1p1F01*", SYMLINK+="hwcdrom", RUN+="/usr/bin/sg_raw /dev/hwcdrom 11 06 20 00 00 00 00 00 01 00"
To automate interface address assignment using the Huawei E3131 built-in DHCP server, edit the exiting file "/etc/network/interfaces" to add the following lines at the end of the existing data:

Code: Select all

allow-hotplug eth1
iface eth1 inet dhcp
Next, test connectivity to the E3131's built-in web server by loading a browser and visiting the address "http://192.168.1.1", This will allow 3G network configuration to be adjusted to suit your SIM card (not always necessary). Most importantly, it will show you whether or not you're connected to a phone network.

Finally, try browsing the Internet. Make sure that you disconnect any existing hard-wired or WiFi interface to ensure you're really connected through the E3131!

Good luck and hope this helps.

Richard White

saif
Posts: 74
Joined: Sun Apr 15, 2012 8:15 pm

Re: Huawei E3131 on Wheezy

Tue Oct 02, 2012 6:17 pm

Looks cool...so let me get this...
You have an IP address of 192.168.123.100 for eth1..is that right?
Which device are you pinging or connecting to with 192.168.1.1 then?..this IP is usually the router on the network...

rcw
Posts: 2
Joined: Tue Oct 02, 2012 7:12 am

Re: Huawei E3131 on Wheezy

Fri Oct 26, 2012 2:42 pm

Sorry to be so late in replying.

Yes, the E3131 establishes a private point-to-point network using netmask 192.168.1.0/24. The connection to the Internet is behind this "in the device". And yes, this address is often used for routers. I guess the assumption is that if you're using a dongle, you won't have a separate LAN connection. Crazy in my opinion!

Richard

creatron
Posts: 5
Joined: Tue Oct 23, 2012 7:32 am

Re: Huawei E3131 on Wheezy

Sun Oct 28, 2012 2:01 pm

Thanks, I used this to connect an Huawei E303 (South Africa), and it works.
Regards
:D

max246
Posts: 9
Joined: Sun Oct 21, 2012 4:20 pm

Re: Huawei E3131 on Wheezy

Wed Nov 07, 2012 4:22 pm

Great it worked fine!
Do you know if the dongle consume more power when is connected? I'd like to disconnect it from internet to save the battery because my project will powered by a battery pack.

cheeves
Posts: 1
Joined: Thu Jan 17, 2013 10:06 am

Re: Huawei E3131 on Wheezy

Thu Jan 17, 2013 10:08 am

thanks for this, worked perfectly with my e303

nickajderian
Posts: 2
Joined: Mon Jan 14, 2013 2:04 pm

Re: Huawei E3131 on Wheezy

Wed Jan 23, 2013 9:25 pm

Works fine with a new Huawei E3231 Dongle.
Amazing knowledge, thank you very much for taking the time to share it!

Spid
Posts: 525
Joined: Sat Jan 19, 2013 12:47 pm

Re: Huawei E3131 on Wheezy

Wed Jan 23, 2013 9:59 pm

nickajderian wrote:Works fine with a new Huawei E3231 Dongle.
Amazing knowledge, thank you very much for taking the time to share it!
I used Sakis3g http://www.sakis3g.org
I will always assume you are running Raspbian for desktop and Raspbmc for XMBC !

Ur5uS
Posts: 2
Joined: Tue Nov 27, 2012 7:53 am

Re: Huawei E3131 on Wheezy

Sat Feb 09, 2013 4:44 pm

Hi,

While in 12d1:14db mode, it is possible to execute http://192.168.1.1/html/switchProjectMode.html

And device will switch to 12d1:1442
after
modprobe
echo “12d1 1442″ > /sys/bus/usb-serial/drivers/option1/new_id

device will available as /dev/ttyUSB0 and /dev/ttyUSB1

Is it possible to execute command similar to
/usr/bin/sg_raw /dev/sr0 11 06 20 00 00 00 00 00 01 00
so device be automatically avaialbe as 12d1:1442

dcuzhang
Posts: 3
Joined: Wed Jul 11, 2012 8:16 pm

Re: Huawei E3131 on Wheezy

Wed Mar 13, 2013 11:10 pm

Code: Select all

ifconfig eth1 192.168.123.100
can be replaced by

Code: Select all

sudo dhclient eth1
this will dynamically assign an ip to eth1.

it may be better to put them on the same local network
e.g

Code: Select all

192.168.1.100

notacake
Posts: 6
Joined: Thu Apr 18, 2013 12:46 pm

Re: Huawei E3131 on Wheezy

Thu Apr 18, 2013 12:51 pm

While in 12d1:14db mode, it is possible to execute http://192.168.1.1/html/switchProjectMode.html
This works in Windows, but it won't load any drivers for the serial modem interfaces. It doesn't seem to produce an effect on the Pi though, but that might be because I don't understand the rest of the instructions:
And device will switch to 12d1:1442
after
modprobe
echo “12d1 1442″ > /sys/bus/usb-serial/drivers/option1/new_id
modprobe what exactly? I assume you mean the option driver, but while 'modprobe option' works, the second command produces 'permission denied' (even run as root).
Is it possible to execute command similar to
/usr/bin/sg_raw /dev/sr0 11 06 20 00 00 00 00 00 01 00
so device be automatically avaialbe as 12d1:1442
Did you find an answer to this? I don't particularly want to have it in 12d1:1442 mode, but I would like to get it in that mode to enter a AT^U2DIAG command to try and get it permanently in 12d1:14db mode without having to modeswitch.

thetrew
Posts: 1
Joined: Thu Apr 25, 2013 2:06 am

Re: Huawei E3131 on Wheezy

Thu Apr 25, 2013 2:10 am

Hello.

I have an E3131 from Orange (UK) plugged into my Pi via a powered USB hub. I have installed Sakis. When I run Sakis, I select:

Connect with 3G > USB Device > HUAWEI HiLink > Failed to connect

What could I be doing wrong? Please could someone help me out before I go insane :0)

Thanks in advance.

ace192
Posts: 8
Joined: Sun Nov 04, 2012 8:07 pm

Re: Huawei E3131 on Wheezy

Tue Jun 04, 2013 9:22 pm

any ideas on a huawei e585 on three? i tried this but didn't seem to work...
Pi,
Pi 2,
Pi 3,
7" touch screen

wkaha
Posts: 2
Joined: Sat Jun 15, 2013 6:27 pm

Re: Huawei E3131 on Wheezy

Sat Jun 15, 2013 6:32 pm

I've had the problem to use my e303 with smsd - smstools.
I could not enable the ttyUSB's persistent. So I was looking for the way, the web switch the mode.

I found out that is is done with an http post performed in a javascript function.

The following script is working for me.
But before you have to switch with usb_modeswitch too 0x14db

Code: Select all

#!/bin/sh

url="http://192.168.1.1/api/device/mode"
xmlheader="<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
data="<request><mode>0</mode></request>"

ifconfig eth1 192.168.1.10 netmask 255.255.255.0
wget --post-data="$xmlheader$data" $url -qO-

yorkyokel
Posts: 1
Joined: Tue Jul 31, 2012 10:24 pm

Re: Huawei E3131 on Wheezy

Sun Jun 16, 2013 12:31 pm

Fantastic guide to setting the E3131 up, there's no way I could have done it before I found this post! Clear and concise but with enough explanation so I could see WHY the various step were needed. The automation steps also worked a treat. Thanks a lot.

One thing that was critical for me however was using 'sudo dhclient eth1' to configure the network rather than 'ifconfig eth1 192.168.1.100'. With the latter I could ping but could not connect to the internet through the dongle.

sadsatan
Posts: 2
Joined: Sun Jun 16, 2013 9:39 pm

Re: Huawei E3131 on Wheezy

Sun Jun 16, 2013 9:59 pm

Hi,

after i put in the code /usr/bin/sg_raw /dev/sr0 11 06 20 00 00 00 00 00 01 00

i get a message SCSI Status:good
Sense information: sense buffer empty

when i check with ifconfig -a i get no eth1
in desktop mode huawei is still a cdrom drv...when i try to eject it i get a error message

what can i do to make it right?
cheers

wkaha
Posts: 2
Joined: Sat Jun 15, 2013 6:27 pm

Re: Huawei E3131 on Wheezy

Mon Jun 17, 2013 9:39 am

sadsatan wrote: when i check with ifconfig -a i get no eth1
in desktop mode huawei is still a cdrom drv...when i try to eject it i get a error message
When the stick isn't in 14db mode, then there is no way to get an ethx interface.
So find out with lsusb. When the modem is there with the id 12d1:1442 you are in
modem / serial mode.

12d1:1f01 - CD Mode
12d1:14db - Web Mode / HiLink
12d1:1442 - Serial Mode

sadsatan
Posts: 2
Joined: Sun Jun 16, 2013 9:39 pm

Re: Huawei E3131 on Wheezy

Mon Jun 17, 2013 1:16 pm

hi,

ID: 12d1:1506

User avatar
katoen58
Posts: 16
Joined: Sun Jun 16, 2013 5:48 pm

Re: Huawei E3131 on Wheezy

Tue Jun 18, 2013 4:35 pm

Hi wkaha,

I was just planning a post on the same problem you solved, so thanks for your work!

I'm quite a newby to Linux, so what kind of script is it? Python (I know) or Java (I don't know, how do I get that to work in Linux; link to a site is OK for me)?

Thanks!
Bart.

User avatar
katoen58
Posts: 16
Joined: Sun Jun 16, 2013 5:48 pm

Re: Huawei E3131 on Wheezy

Fri Jun 21, 2013 7:39 pm

Hi wkaha and others,

with a little help from a friend I managed to get your script working and my E303 switched to "12d1:1442 - Serial Mode". But still Sakis3G "Failed to connect" like thetrew described above, although I have ttyUSB0 and ttyUSB1 working, but no eth*..... :(

In "12d1:14db - Web Mode / HiLink", it's working with cdc_ether as driver, eth2 is on with address 192.168.1.100, but I can't get ttyUSB0 and ttyUSB1 working. Though, I can connect to the internet through the E303's built-in web server, so that's the good thing.
Because I like to use the Raspi for a stand-alone project that will send me an email now and then, I like to connect via the commandline (i.e. a Python-script), not by loading a browser and visiting the address "http://192.168.1.1", fill in PIN and click on "Submit". Is that possible? Also when I use a PIN-code on the SIM? Good to know that the RasPi will be switched on and off every 6 hours to save power.

Thanks!

Bart.

EasyViber
Posts: 3
Joined: Tue Jan 15, 2013 1:44 pm

Re: Huawei E3131 on Wheezy

Sat Jul 13, 2013 2:04 pm

Seems my Huawei E3131 is not as yours. Mine seems to be Huawei E3131s-2 and after switching mode it gets detected as USB id 12d1:1506 (Huawei E398 LTE/UMTS/GSM modem) instead USB id 12d1:14db :(

After that (ofc.) I don't get "eth1" and rest of your instructions fail.

Aparently there are at least 2 versions of E3131 (E3131s-2 and E3131s-h2) so look carefully what you get. First one supports serial & qmi while other supports serial & ncm & mbim.
http://www.dd-wrt.com/wiki/index.php/3G_/_3.5G#HUAWEI

And I went and bought stupid E3131 after I looked at this topic and after I've seen you got it working. :x

faceless
Posts: 8
Joined: Tue May 22, 2012 11:19 am

Re: Huawei E3131 on Wheezy

Fri Aug 09, 2013 10:30 am

If you're using the E3131 as a backup network connection rather than your primary, rather than

Code: Select all

allow-hotplug eth1
ifconfig eth1 dhcp
in your /etc/network/interfaces file, try this:

Code: Select all

allow-hotplug eth1
iface eth1 inet static
        address 192.168.1.2
        netmask 255.255.255.0
        gateway 192.168.1.1
        metric 1000
This will keep the E3131 online, but the higher metric will ensure traffic isn't routed over it unless there is no other gateway.

chorlton2080
Posts: 129
Joined: Sun Dec 23, 2012 9:44 pm

Re: Huawei E3131 on Wheezy

Sun Aug 18, 2013 1:30 pm

This works so well, especially given the Sakis3g link no longer works! I would rather download the tools from the official repository (i.e. the tool you describe) than install some code from a third party I really can't vouch for.

The latest Thee Huawei 3231 can even be powered directly from the Model B USB port (haven't tried on the Model A).

The only thing missing is the ability to open ports on the 3G connection so I can connect in to Motion or to Apache. There are no options on the dongle homepage to allow this: I wonder if you can using the 3G WiFi dongles?

This topic should be a "sticky" for everyone's easy reference.

chorlton2080
Posts: 129
Joined: Sun Dec 23, 2012 9:44 pm

Re: Huawei E3131 on Wheezy

Fri Oct 11, 2013 7:20 pm

I've reposted this from another thread I've created, but it's relevant here too.

I needed a static IP on my home router with a 192.168.0.x address space (as my router didn't do MAC IP assignment reliably). I also needed to use DHCP on the 3G dongle, or add a static IP within the 192.168.1.x address space. The problem was that the namespace on each device is different, causing problems with /etc/resolv.conf as it is overwritten each time by DHCP.

To "cure" this problem of DHCP overwriting the resolve.conf, I simply did the following:

Code: Select all

sudo nano /etc/resolv.conf
delete everything and add the following:

Code: Select all

nameserver x.x.x.x
Where "x.x.x.x" is your favourite free DNS service. It has to be outside the local network because of the 192.168.0.x/192.168.1.x namespace issues.

Importantly, then make the file unchangable by anyone - including by the DHCP service!

Code: Select all

sudo chattr +i /etc/resolv.conf
Once done I can freely sway the 3G dongle and wifi dongle. Happy Days.

SButcher
Posts: 2
Joined: Mon Jun 17, 2013 7:34 am

Re: Huawei E3131 on Wheezy

Wed Nov 06, 2013 8:59 am

Thanks for the advice, but I had a slightly different approach.

I recompiled the kernel on my Pi, included USB networking and RNDIS. This may have been unneccessary, but I couldn't find the kernel modules.
Then installed usb_modeswitch

Code: Select all

sudo apt-get install usb-modeswitch
Then pulled the latest udev rules from the git repository

Code: Select all

wget https://github.com/digidietze/usb-modeswitch-data/raw/master/40-usb_modeswitch.rules
mv 40-usb_modeswitch.rules /lib/udev/rules.d/
Then I modified /etc/network/interfaces, eth0 as this was on a model A:

Code: Select all

allow-hotplug eth0
iface eth0 inet dhcp
Rebooted, and interface came up as expected.
Pi hot-spot fully functional. :)

Return to “Networking and servers”