In the previous post I told you about the different modes a Huawei USB “internet stick” may have and what for. And since we want to make an SMS-Email gateway, we’ll want to put our USB stick into modem mode so that it will act as USB serial device that we can control directly as modem, and send modem commands to it.

When I connect my Huawei E3531 to my Ubuntu machine and run lsusb I will see something like this:

12d1:14dc Huawei Technologies Co., Ltd.

This is the USB stick, in the “router mode” where it acts as USB Ethernet stick and the firmware on the stick handles the modem part for us. But we don’t want that! We want modem mode!

Running dmesg | grep GSM will show:

usbserial: USB Serial support registered for GSM modem (1-port)

But we’re not quite there yet! What we need to do now is to change the mode, using usb_modeswitch!

On a system running Debian/Ubuntu/Raspbian/Mint run:

sudo apt install usb-modeswitch usb-modeswitch-data

Now we create a new file with:

sudo nano /etc/usb_modeswitch.d/12d1:1f01

And inside it we add the following contents:

# Huawei E3531 modem mode
TargetVendor=0x12d1
TargetProduct=0x1f01 

MessageContent="55534243123456780000000000000011062000000100000000000000000000"
NoDriverLoading=1

Hit CTRL + X, then confirm with Y and hit enter twice to save.

If usb-modeswitch was already installed, you should be able to just plug the device out and back in. Otherwise, reboot now.

Now if we run lsusb again, we will see:

12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA Modem

Interesting! As you can see the ID changed and the text shows it is indeed a modem!

Now let’s try dmesg | grep GSM:

[  836.136279] option 1-5:1.0: GSM modem (1-port) converter detected
[  836.136377] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB0
[  836.136457] option 1-5:1.1: GSM modem (1-port) converter detected
[  836.136520] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB1
[  836.136585] option 1-5:1.2: GSM modem (1-port) converter detected
[  836.136644] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB2

Yes indeed! We now have the modem exposed as USB serial device. That’s great!

We should now be able to connect to it as serial device and send modem commands!

We’re one step closer to our SMS-Email gateway! We’ll continue in the next part…