Internet Connection with Twilio Super SIM and Sixfab Base HAT using libqmi

Cellular modules that are based on the Qualcomm chipsets support the QMI interface. The libqmi can be used to establish QMI interface for mini PCIe modules such as Quectel EC25, EG25-G, EC21, UC20-G and Telit LE910C1, LE910C4 with the Raspberry Pi 3G/4G & LTE Base HAT.

This is a minimal brief tutorial to establish the connection, Reference sites are listed at the end of the tutorial.

Please note that the below tutorial assumes that you have already completed your hardware setup, if not please follow getting started.

Before we start, check the compatibility of the module.

lsusb -t

should return driver information such as qmi-wwan(opensource) or GobiNet(provided by Qualcomm) as shown below. Both drivers work fine with the libqmi.

   |__ Port 4: Dev 6, If 4, Class=Vendor Specific Class, Driver=qmi_wwan, 480M
⚙️ Module Configuration

Before running the PPP/QMI make sure the module is configured to the right settings.
For Quectel Modules:
AT+QCFG="usbnet" should return 0, otherwise,send AT+QCFG="usbnet",0 then reboot the module after 10 seconds AT+CFUN=1,1

For Telit Modules:
AT#USBCFG? should return 0, otherwise,send AT#USBCFG=0 then reboot the module after 10 seconds ,AT#REBOOT

For sending AT commands, you may check the Sending AT Commands tutorial.
Note: In case of the driver error please refer to the driver guide of the modules.

First, install the required packages.

sudo apt update && sudo apt install libqmi-utils udhcpc

libqmi-utils installs two main utilities (qmi-cli tool and qmi-network helper script), they are used for interactions with the modem (for more details check man qmi-cli)

Now make sure the module is ready, it can be done with the following command:

sudo qmicli -d /dev/cdc-wdm0 --dms-get-operating-mode

This should return 'online'. If not, then try:

sudo qmicli -d /dev/cdc-wdm0 --dms-set-operating-mode='online'

Now configure the network interface for the raw-ip protocol.

sudo ip link set wwan0 down
echo 'Y' | sudo tee /sys/class/net/wwan0/qmi/raw_ip
sudo ip link set wwan0 up

One can confirm the data format using

sudo qmicli -d /dev/cdc-wdm0 --wda-get-data-format

Once the wwan0 is up, connect the mobile network.

sudo qmicli -p -d /dev/cdc-wdm0 --device-open-net='net-raw-ip|net-no-qos-header' --wds-start-network="apn='super',ip-type=4" --client-no-release-cid

Lastly, configure the IP address and the default route with udhcpc.

sudo udhcpc -q -f -i wwan0
pi@raspberrypi:~ $ sudo udhcpc -q -f -i wwan0 udhcpc: started, v1.30.1 No resolv.conf for interface wwan0.udhcpc udhcpc: sending discover udhcpc: sending select for udhcpc: lease of obtained, lease time 7200 Too few arguments. Too few arguments.

Now check the assigned IP address and test the connection.

pi@raspberrypi:~ $ ifconfig wwan0 wwan0: flags=4305 mtu 1500 inet netmask destination inet6 fe80::abc4:a1b5:5e84:92f2 prefixlen 64 scopeid 0x20 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC) RX packets 3 bytes 640 (640.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 13 bytes 2694 (2.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
pi@raspberrypi:~ $ ping -I wwan0 -c 5 PING ( from wwan0: 56(84) bytes of data. 64 bytes from ( icmp_seq=1 ttl=29 time=247 ms 64 bytes from ( icmp_seq=2 ttl=29 time=205 ms 64 bytes from ( icmp_seq=3 ttl=29 time=207 ms 64 bytes from ( icmp_seq=4 ttl=29 time=204 ms 64 bytes from ( icmp_seq=5 ttl=29 time=216 ms --- ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 8ms rtt min/avg/max/mdev = 204.050/215.839/247.004/16.201 ms
Enjoy your internet connection


We recommend going through the section on troubleshooting as it covers more common issues with establishing and maintaining a network connection. Please check out the troubleshooting guide.