3. Installing 4G USB modem to Raspberry Pi

4G USB modem
&
RaspberryPi

HUAWEI E3372 modem

If you are using HUAWEI E3372, it can plug & play on Raspberry Pi, no need to install any program.


HUAWEI E3370 modem

I have an old HUAWEI E3370 modem that needs config manually. The method also can help me find the problem when the modem didn’t work.

Did the USB modem loaded?

Run the command below in you RPi, to check did the USB modem loaded.

$ lsusb | grep Huawei
12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard

Did the E3370 loaded?

The 12d1 is Huawei and the 1506 is E3370 modem.

$ dmesg | grep 1506
idVendor=12d1, idProduct=1506, bcdDevice= 1.02

Install wvdial

If the modem has been loaded but it didn’t dial up. You can install the wvdial.

$ sudo apt-get install wvdial

The default config of wvdial is fine for me. If you need to edit it, the config file is here:

$ sudo pico /etc/wvdial.conf

It is the default config file:

[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0
Modem Type = Analog Modem
Baud = 9600
New PPPD = yes
Modem = /dev/ttyUSB0
ISDN = 0
Phone = *99#
Password = internet
Username = internet
Stupid Mode = on

Testing the dial up:

$ sudo wvdial

It is the success dial up screen-print:

--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
ATDT*99#
CONNECT 150000000
--> Carrier detected.  Starting PPP immediately.
--> Starting pppd at Sun Oct 18 14:45:08 2020
--> Pid of pppd: 1329
--> Using interface ppp0
--> pppd: X/?[01]X/?[01]
--> local  IP address xxx.xxx.xxx.xxx
--> pppd: X/?[01]X/?[01]
--> remote IP address xxx.xxx.xxx.xxx
--> pppd: X/?[01]X/?[01]
--> primary   DNS address xxx.xxx.xxx.xxx
--> pppd: X/?[01]X/?[01]
--> secondary DNS address xxx.xxx.xxx.xxx
--> pppd: X/?[01]X/?[01]

Create the service

I need the USB modem can auto dial-up, I created a wvdial.service file.

$ sudo pico /etc/systemd/system/wvdial.service
[Unit]
Description=wvdial

[Service]
ExecStart=/usr/bin/wvdial
Restart=on-failure
RestartSec=5

Add the code to the 99-com.rules file. It will call the wvdial.service when the USB modem loaded.

$ sudo pico /etc/udev/rules.d/99-com.rules
SUBSYSTEM=="tty", KERNEL=="ttyUSB0", TAG+="systemd", ENV{SYSTEMD_WANTS}+="wvdial.service"

Testing the connection

Run the command:

ifconfig

If the modem runs correctly, you can find the ppp0 output:

ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet xxx.xxx.xxx.xxx  netmask 255.255.255.255  destination 10.64.64.64
        ppp  txqueuelen 3  (Point-to-Point Protocol)
        RX packets 11065  bytes 1348146 (1.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12168  bytes 1585065 (1.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

If you found any mistake in the document or you have difficulty following the setups, please leave your comments to me. Your comments can help me to improve this article. Thank you!

RC Bellergy

Next: 4. Install Zerotier

12 thoughts on “3. Installing 4G USB modem to Raspberry Pi”

  1. My raspberry also sports a wwan0 interface when i connect my E3272. Can the wwan0 concurrent presence with ppp0 become a problem?

  2. ubuntu@ubuntu:~$ sudo wvdial
    –> WvDial: Internet dialer version 1.61
    –> Initializing modem.
    –> Sending: ATZ
    COMMAND NOT SUPPORT
    –> Sending: ATQ0
    COMMAND NOT SUPPORT
    –> Re-Sending: ATZ
    COMMAND NOT SUPPORT
    –> Modem not responding.

    i am getting this error while following

    1. @AFZAL P A
      The command get “Modem not responding”. What is the ouput when you run the commands below?
      lsusb | grep Huawei
      dmesg | grep 1506

      1. ubuntu@ubuntu:~$ lsusb
        Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
        Bus 001 Device 005: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard
        Bus 001 Device 003: ID 413c:2113 Dell Computer Corp.
        Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
        Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
        ubuntu@ubuntu:~$

        ubuntu@ubuntu:~$ dmesg | grep 1506
        [ 22.158787] usb 1-1.3: New USB device found, idVendor=12d1, idProduct=1506, bcdDevice= 1.02

      2. ubuntu@ubuntu:~$ dmesg | grep 1506
        [ 22.158787] usb 1-1.3: New USB device found, idVendor=12d1, idProduct=1506, bcdDevice= 1.02

        ubuntu@ubuntu:~$ lsusb
        Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
        Bus 001 Device 005: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard
        Bus 001 Device 003: ID 413c:2113 Dell Computer Corp.
        Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
        Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
        ubuntu@ubuntu:~$ ^C
        I am not getting ppp0 interface on ifconfig

        ubuntu@ubuntu:~$ sudo wvdial
        –> WvDial: Internet dialer version 1.61
        –> Initializing modem.
        –> Sending: ATZ
        OK
        –> Sending: ATQ0 V1 E1 S0=0
        OK
        –> Sending: AT+CGDCONT=1,”IP”,”airtelgprs.com”
        AT+CGDCONT=1,”IP”,”airtelgprs.com”
        OK
        –> Modem initialized.
        –> Sending: ATDT99#
        –> Waiting for carrier.
        ATDT
        99#
        CONNECT 150000000
        –> Carrier detected. Starting PPP immediately.
        –> Starting pppd at Tue Sep 6 04:32:55 2022
        –> Pid of pppd: 2785
        –> Using interface ppp0
        –> Disconnecting at Tue Sep 6 04:33:26 2022
        –> The PPP daemon has died: A modem hung up the phone (exit code = 16)
        –> man pppd explains pppd error codes in more detail.
        –> Try again and look into /var/log/messages and the wvdial and pppd man pages for more information.
        –> Auto Reconnect will be attempted in 5 seconds
        –> Initializing modem.
        –> Sending: ATZ
        –> Sending: ATQ0
        –> Re-Sending: ATZ
        –> Modem not responding.
        –> Initializing modem.
        –> Sending: ATZ
        –> Sending: ATQ0
        –> Re-Sending: ATZ
        –> Modem not responding.
        –> Disconnecting at Tue Sep 6 04:33:47 2022
        ubuntu@ubuntu:~$

      3. Please help i am using E3372 huawai 4g dongle and i tried with both airtel and vodafone as carrier.Bu when i check ifconfig no interface on ppp0. please help
        ubuntu@ubuntu:~$ dmesg | grep 1506
        [ 22.158787] usb 1-1.3: New USB device found, idVendor=12d1, idProduct=1506, bcdDevice= 1.02

        ubuntu@ubuntu:~$ lsusb
        Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
        Bus 001 Device 005: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard
        Bus 001 Device 003: ID 413c:2113 Dell Computer Corp.
        Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
        Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
        ubuntu@ubuntu:~$ ^C
        I am not getting ppp0 interface on ifconfig

        ubuntu@ubuntu:~$ sudo wvdial
        –> WvDial: Internet dialer version 1.61
        –> Initializing modem.
        –> Sending: ATZ
        OK
        –> Sending: ATQ0 V1 E1 S0=0
        OK
        –> Sending: AT+CGDCONT=1,”IP”,”airtelgprs.com”
        AT+CGDCONT=1,”IP”,”airtelgprs.com”
        OK
        –> Modem initialized.
        –> Sending: ATDT99#
        –> Waiting for carrier.
        ATDT99#
        CONNECT 150000000
        –> Carrier detected. Starting PPP immediately.
        –> Starting pppd at Tue Sep 6 04:32:55 2022
        –> Pid of pppd: 2785
        –> Using interface ppp0
        –> Disconnecting at Tue Sep 6 04:33:26 2022
        –> The PPP daemon has died: A modem hung up the phone (exit code = 16)
        –> man pppd explains pppd error codes in more detail.
        –> Try again and look into /var/log/messages and the wvdial and pppd man pages for more information.
        –> Auto Reconnect will be attempted in 5 seconds
        –> Initializing modem.
        –> Sending: ATZ
        –> Sending: ATQ0
        –> Re-Sending: ATZ
        –> Modem not responding.
        –> Initializing modem.
        –> Sending: ATZ
        –> Sending: ATQ0
        –> Re-Sending: ATZ
        –> Modem not responding.
        –> Disconnecting at Tue Sep 6 04:33:47 2022
        ubuntu@ubuntu:~$

  3. sudo pico /etc/udev/rules.d99-com.rules

    should be:

    sudo pico /etc/udev/rules.d/99-com.rules

    overall this is the best solution!
    cheers

  4. Hi, There is an error in: “$ sudo pico /etc/udev/rules.d99-com.rules” should be “sudo pico /etc/udev/rules.d/99-com.rules”

Leave a Reply to bellergyCancel reply

%d