Sunday, December 13, 2020

Connecting USB GSM / 3G / 4G Dongles to Raspberry Pi 4 (Huawei E303, usb-modeswitch, and Gammu)

USB cellular modems (such as the ubiquitous Huawei E303, E173, and E3372) enable Raspberry Pi 4 projects to send SMS notifications, handle emergency alerts, and provide cellular backup connectivity. However, modern USB modems initially boot into a virtual CD-ROM storage mode (ZeroCD) to deliver Windows drivers, requiring usb-modeswitch to toggle them into serial modem mode.

Hardware: Raspberry Pi 4 • Huawei E303 USB Dongle • usb-modeswitch • Gammu SMS Gateway

1. Installing usb-modeswitch and Gammu

sudo apt-get update
sudo apt-get install usb-modeswitch usb-modeswitch-data gammu minicom -y

2. Switching from Mass Storage to Modem Mode

Check lsusb to identify your device vendor and product ID:

# Example: ID 12d1:1f01 (Mass Storage Mode)
lsusb | grep Huawei

# Mode-switch into serial modem mode (12d1:1001 or 12d1:14db):
sudo usb_modeswitch -v 12d1 -p 1f01 -M '55534243123456780000000000000011062000000100000000000000000000'

Confirm the modem serial nodes are created under /dev/ttyUSB0, /dev/ttyUSB1, and /dev/ttyUSB2.

3. Sending a Test SMS via Gammu

Configure ~/.gammurc:

[gammu]
port = /dev/ttyUSB0
connection = at115200

Send an automated test message:

echo "Alert: Raspberry Pi online!" | gammu sendsms TEXT +1234567890

2 comments:

  1. Thanks, Nice tuto, for the tplink usb hub , could you inform what hub version you have that has VIA VL812 chipset? As I understood there are some versions come with different chipset like V2 comes with RTS5411.

    ReplyDelete
    Replies
    1. I have tested v1 and v3 and dongles worked fine on both. However, the problem with v1 is that it does not turn on automatically when the power cable was disconnected and connected again, you always need to press the power button to turn it on each time it is connected to power

      Delete

How Google Antigravity Solved the Mysterious NVIDIA Sleep Reboot on My Dell Inspiron 7567 (Ubuntu Linux)

If you run modern Ubuntu or Linux on a Dell Inspiron 15 Gaming (7567) or a similar 7th-gen Intel laptop paired with an NVIDIA GeForce GTX ...